Skip to content

Commit

Permalink
Move global instrumentation to the init stage.
Browse files Browse the repository at this point in the history
fixes #31
  • Loading branch information
evanderkoogh committed Jul 28, 2023
1 parent 4d5fa63 commit 95452d4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import { instrumentGlobalCache } from './instrumentation/cache.js'
import { createQueueHandler } from './instrumentation/queue.js'
import { DOClass, instrumentDOClass } from './instrumentation/do.js'

instrumentGlobalCache()
instrumentGlobalFetch()

type FetchHandler = ExportedHandlerFetchHandler<unknown, unknown>
type QueueHandler = ExportedHandlerQueueHandler

Expand Down Expand Up @@ -71,6 +68,8 @@ function isSpanExporter(exporterConfig: ExporterConfig): exporterConfig is SpanE
let initialised = false
function init(config: ResolvedTraceConfig): void {
if (!initialised) {
instrumentGlobalCache()
instrumentGlobalFetch()
propagation.setGlobalPropagator(new W3CTraceContextPropagator())
const resource = createResource(config)
const spanProcessor = new BatchTraceSpanProcessor()
Expand Down

0 comments on commit 95452d4

Please sign in to comment.