Skip to content

Commit

Permalink
Only set params on router layer
Browse files Browse the repository at this point in the history
To avoid setting the params in many different spans, potentially
interfering with custom instrumentation on those same params, only
set the params on the router layer.
  • Loading branch information
unflxw committed Nov 3, 2022
1 parent f65b59a commit ec9aa36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changesets/only-set-params-on-router-layer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "fix"
---

Only set the params on Koa router layer, instead of on all layers.
3 changes: 2 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { RedisDbStatementSerializer } from "./instrumentation/redis/serializer"
import { RedisInstrumentation as Redis4Instrumentation } from "@opentelemetry/instrumentation-redis-4"
import { RedisInstrumentation } from "@opentelemetry/instrumentation-redis"
import { SpanProcessor, TestModeSpanProcessor } from "./span_processor"
import { KoaLayerType } from "@opentelemetry/instrumentation-koa"

const DefaultInstrumentations = {
"@opentelemetry/instrumentation-express": ExpressInstrumentation,
Expand Down Expand Up @@ -244,7 +245,7 @@ export class Client {
},
"@opentelemetry/instrumentation-koa": {
requestHook: function (_span, info) {
if (sendParams) {
if (sendParams && info.layerType === KoaLayerType.ROUTER) {
const queryParams = info.context.request.query
setParams(queryParams)
}
Expand Down

0 comments on commit ec9aa36

Please sign in to comment.