diff --git a/.changesets/report-request-parameters-for-restify.md b/.changesets/report-request-parameters-for-restify.md new file mode 100644 index 00000000..b93a7d22 --- /dev/null +++ b/.changesets/report-request-parameters-for-restify.md @@ -0,0 +1,6 @@ +--- +bump: "patch" +type: "add" +--- + +Report request parameters for restify apps. This is reported automatically. You can disable parameter reporting with the AppSignal `sendParams: false` configuration option. diff --git a/package-lock.json b/package-lock.json index 06dbdf3f..d3a5de3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@appsignal/nodejs", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@appsignal/nodejs", - "version": "3.0.1", + "version": "3.0.2", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -27,7 +27,7 @@ "@opentelemetry/instrumentation-pg": "^0.33.0", "@opentelemetry/instrumentation-redis": "^0.34.0", "@opentelemetry/instrumentation-redis-4": "^0.34.0", - "@opentelemetry/instrumentation-restify": "^0.31.0", + "@opentelemetry/instrumentation-restify": "^0.32.0", "@opentelemetry/sdk-node": "^0.34.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@prisma/instrumentation": "^4.4.0", @@ -1895,9 +1895,9 @@ } }, "node_modules/@opentelemetry/instrumentation-restify": { - "version": "0.31.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-restify/-/instrumentation-restify-0.31.0.tgz", - "integrity": "sha512-b0AWFZ9+tm4Iaydt1AquBpsQty+Uv1YQ3C9Jb4/JTknWDWW63tb8FoCcALMPYDulvOgH+PPDvtvZY0Q0Imbstg==", + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-restify/-/instrumentation-restify-0.32.0.tgz", + "integrity": "sha512-Jyt6WVr5LGfQDYoAlavgNJLLkIUABiqKi/5C0eucrbc9XGn+BeEDo0nrzo/4yaW37VAbA0rn4c271OMHp7W5iw==", "dependencies": { "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.34.0", @@ -12680,9 +12680,9 @@ } }, "@opentelemetry/instrumentation-restify": { - "version": "0.31.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-restify/-/instrumentation-restify-0.31.0.tgz", - "integrity": "sha512-b0AWFZ9+tm4Iaydt1AquBpsQty+Uv1YQ3C9Jb4/JTknWDWW63tb8FoCcALMPYDulvOgH+PPDvtvZY0Q0Imbstg==", + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-restify/-/instrumentation-restify-0.32.0.tgz", + "integrity": "sha512-Jyt6WVr5LGfQDYoAlavgNJLLkIUABiqKi/5C0eucrbc9XGn+BeEDo0nrzo/4yaW37VAbA0rn4c271OMHp7W5iw==", "requires": { "@opentelemetry/core": "^1.7.0", "@opentelemetry/instrumentation": "^0.33.0", diff --git a/package.json b/package.json index e00cada4..e29a5ba7 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@opentelemetry/instrumentation-pg": "^0.33.0", "@opentelemetry/instrumentation-redis": "^0.34.0", "@opentelemetry/instrumentation-redis-4": "^0.34.0", - "@opentelemetry/instrumentation-restify": "^0.31.0", + "@opentelemetry/instrumentation-restify": "^0.32.0", "@opentelemetry/sdk-node": "^0.34.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@prisma/instrumentation": "^4.4.0", diff --git a/src/client.ts b/src/client.ts index cfc212fa..7ba16dfb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -37,7 +37,10 @@ import { PrismaInstrumentation } from "@prisma/instrumentation" import { RedisDbStatementSerializer } from "./instrumentation/redis/serializer" import { RedisInstrumentation as Redis4Instrumentation } from "@opentelemetry/instrumentation-redis-4" import { RedisInstrumentation } from "@opentelemetry/instrumentation-redis" -import { RestifyInstrumentation } from "@opentelemetry/instrumentation-restify" +import { + RestifyInstrumentation, + LayerType as RestifyLayerType +} from "@opentelemetry/instrumentation-restify" import { SpanProcessor, TestModeSpanProcessor } from "./span_processor" const DefaultInstrumentations = { @@ -300,6 +303,21 @@ export class Client { "@opentelemetry/instrumentation-redis-4": { dbStatementSerializer: RedisDbStatementSerializer }, + "@opentelemetry/instrumentation-restify": { + requestHook: (span, info) => { + if ( + sendParams && + info.layerType === RestifyLayerType.REQUEST_HANDLER + ) { + const request = info.request + const params = Object.assign( + request.params || {}, + request.query || {} + ) + setParams(params, span) + } + } + }, "@prisma/instrumentation": { middleware: true }, diff --git a/test/restify/app/src/app.ts b/test/restify/app/src/app.ts index 41fe0272..4969f6b7 100644 --- a/test/restify/app/src/app.ts +++ b/test/restify/app/src/app.ts @@ -6,6 +6,7 @@ function respond(req: any, res: any, next: any) { } const server = restify.createServer() +server.use(restify.plugins.queryParser()) server.get("/", function (req: any, res: any, next: any) { res.send("home") return next()