File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @microlabs/otel-cf-workers " : minor
3+ ---
4+
5+ Add option to disable auto-instrumentation of global fetch and cache API
Original file line number Diff line number Diff line change @@ -76,8 +76,12 @@ function isSpanExporter(exporterConfig: ExporterConfig): exporterConfig is SpanE
7676let initialised = false
7777function init ( config : ResolvedTraceConfig ) : void {
7878 if ( ! initialised ) {
79- instrumentGlobalCache ( )
80- instrumentGlobalFetch ( )
79+ if ( config . instrumentation . instrumentGlobalCache ) {
80+ instrumentGlobalCache ( )
81+ }
82+ if ( config . instrumentation . instrumentGlobalFetch ) {
83+ instrumentGlobalFetch ( )
84+ }
8185 propagation . setGlobalPropagator ( config . propagator )
8286 const resource = createResource ( config )
8387
@@ -135,6 +139,10 @@ function parseConfig(supplied: TraceConfig): ResolvedTraceConfig {
135139 service : supplied . service ,
136140 spanProcessors,
137141 propagator : supplied . propagator || new W3CTraceContextPropagator ( ) ,
142+ instrumentation : {
143+ instrumentGlobalCache : supplied . instrumentation ?. instrumentGlobalCache ?? true ,
144+ instrumentGlobalFetch : supplied . instrumentation ?. instrumentGlobalFetch ?? true ,
145+ } ,
138146 }
139147 } else {
140148 const exporter = isSpanExporter ( supplied . exporter ) ? supplied . exporter : new OTLPExporter ( supplied . exporter )
Original file line number Diff line number Diff line change @@ -29,13 +29,19 @@ export interface SamplingConfig<HS extends HeadSamplerConf = HeadSamplerConf> {
2929 tailSampler ?: TailSampleFn
3030}
3131
32+ export interface InstrumentationOptions {
33+ instrumentGlobalFetch ?: boolean
34+ instrumentGlobalCache ?: boolean
35+ }
36+
3237interface TraceConfigBase {
3338 service : ServiceConfig
3439 handlers ?: HandlerConfig
3540 fetch ?: FetcherConfig
3641 postProcessor ?: PostProcessorFn
3742 sampling ?: SamplingConfig
3843 propagator ?: TextMapPropagator
44+ instrumentation ?: InstrumentationOptions
3945}
4046
4147interface TraceConfigExporter extends TraceConfigBase {
@@ -59,6 +65,7 @@ export interface ResolvedTraceConfig extends TraceConfigBase {
5965 sampling : Required < SamplingConfig < Sampler > >
6066 spanProcessors : SpanProcessor [ ]
6167 propagator : TextMapPropagator
68+ instrumentation : InstrumentationOptions
6269}
6370
6471export interface DOConstructorTrigger {
You can’t perform that action at this time.
0 commit comments