Skip to content

Commit

Permalink
Only instrument fs with parent span
Browse files Browse the repository at this point in the history
To avoid having spans consisting entirely of an `fs` invocation,
such as those originating from reading files on boot, only instrument
`fs` calls if there already is a root span.
  • Loading branch information
unflxw committed Dec 29, 2022
1 parent 92851af commit 7637610
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changesets/only-instrument-fs-with-parent-span.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "fix"
---

Prevent creating fs-only samples by only creating an fs span if there is a parent span present.
6 changes: 6 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { setParams, setSessionData } from "./helpers"
import { BaseLogger, Logger, LoggerLevel } from "./logger"

import { Instrumentation } from "@opentelemetry/instrumentation"
import { trace } from "@opentelemetry/api"
import {
ExpressInstrumentation,
ExpressLayerType
Expand Down Expand Up @@ -299,6 +300,11 @@ export class Client {
},
"@prisma/instrumentation": {
middleware: true
},
"@opentelemetry/instrumentation-fs": {
createHook: () => {
return trace.getActiveSpan() !== undefined
}
}
}
}
Expand Down

0 comments on commit 7637610

Please sign in to comment.