Skip to content

Commit

Permalink
[pinpoint-apm#98] Fix no details error case informations to Error ca…
Browse files Browse the repository at this point in the history
…llstack

By using the string return value of the stack in the toString method of Error, the developer can check the error information in detail.
Fix redis 4.0 redis connection error
   - upgrade testcontainer to v7
  • Loading branch information
feelform committed Sep 12, 2023
1 parent eade04c commit f72c657
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 103 deletions.
3 changes: 2 additions & 1 deletion lib/context/span-event-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ class SpanEventRecorder {
recordException(error, isError) {
if (this.spanEvent && error) {
const metaInfo = StringMetaService.get(error.name || 'Error')
const errorMessage = error && typeof error.stack === 'string' ? error.stack.split(/\r?\n/, 2).join('') : ''
this.spanEvent.exceptionInfo = {
intValue: metaInfo.stringId,
stringValue: error.toString(),
stringValue: errorMessage,
}
if (this.span && isError) {
this.span.err = 1
Expand Down
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinpoint-node-agent",
"version": "0.9.0-next.1",
"version": "0.9.0-next.2",
"main": "index.js",
"scripts": {
"test": "tape ./test/**/*.test.js",
Expand Down Expand Up @@ -85,12 +85,6 @@
"redis-mock": "^0.49.0",
"rimraf": "^2.6.2",
"tape": "^4.9.1",
"testcontainers": "^2.8.0"
},
"resolutions": {
"semver": "^7.5.3"
},
"volta": {
"node": "16.20.1"
"testcontainers": "^7.24.0"
}
}
2 changes: 1 addition & 1 deletion test/agent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ test('Should initialize agent', function (t) {

const agent = require('./support/agent-singleton-mock')
t.ok(agent)
t.equal(agent.pinpointClient.agentInfo.agentVersion, '0.9.0-next.1', 'agent version from package.json')
t.equal(agent.pinpointClient.agentInfo.agentVersion, '0.9.0-next.2', 'agent version from package.json')
})
2 changes: 1 addition & 1 deletion test/instrumentation/fix-async-call-stack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test(`fix redis call stack depth`, async (t) => {
const redis = require('redis')
const client = redis.createClient(
container.getMappedPort(6379),
container.getContainerIpAddress(),
container.getHost(),
)

client.set("key", "value", async function (error) {
Expand Down
280 changes: 192 additions & 88 deletions test/instrumentation/module/express.test.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/instrumentation/module/fix-redis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test(`redis destination id`, async (t) => {

const client = redis.createClient(
container.getMappedPort(6379),
container.getContainerIpAddress(),
container.getHost(),
)

client.on("error", function (error) {
Expand Down Expand Up @@ -65,7 +65,7 @@ test("ioredis destination id", async function (t) {
const port = container.getMappedPort(6379)
const redis = new Redis(
port,
container.getContainerIpAddress(),
container.getHost(),
)
redis.on("error", function (error) {
console.error(error)
Expand Down Expand Up @@ -119,7 +119,7 @@ test(`Fix app crash without callback function https://github.com/pinpoint-apm/pi
const redis = require('redis')

const client = redis.createClient({
host: container.getContainerIpAddress(),
host: container.getHost(),
port: container.getMappedPort(6379),
db: 3,
})
Expand Down
2 changes: 1 addition & 1 deletion test/instrumentation/module/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test(`outgoing request URL escape a bug`, async (t) => {
t.true(agent.dataSender.mockSpanChunk.spanEventList.length == 2, `spanEventList`)

const spanEvent = agent.dataSender.mockSpanChunk.spanEventList[1]

t.equal(spanEvent.annotations[0].value.stringValue, "GET", "URL")
t.equal(spanEvent.annotations[1].value.stringValue, "www.naver.com/", "URL")
agent.completeTraceObject(trace)
Expand Down

0 comments on commit f72c657

Please sign in to comment.