1- import { type ReadableSpan , SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
1+ import { type ReadableSpan , SimpleSpanProcessor , SpanProcessor } from '@opentelemetry/sdk-trace-base'
22import * as logfireApi from '@pydantic/logfire-api'
33import { resolveBaseUrl , serializeAttributes , ULIDGenerator } from '@pydantic/logfire-api'
44import { instrument as baseInstrument , TraceConfig } from '@pydantic/otel-cf-workers'
@@ -15,6 +15,10 @@ type ConfigOptionsBase = Pick<
1515>
1616
1717export interface InProcessConfigOptions extends ConfigOptionsBase {
18+ /**
19+ * Additional span processors to add to the tracer provider.
20+ */
21+ additionalSpanProcessors ?: SpanProcessor [ ]
1822 baseUrl ?: string
1923 /**
2024 * Whether to log the spans to the console in addition to sending them to the Logfire API.
@@ -36,7 +40,11 @@ function getInProcessConfig(config: InProcessConfigOptions): (env: Env) => Trace
3640 const baseUrl = resolveBaseUrl ( env , config . baseUrl , token )
3741 const resolvedEnvironment = config . environment ?? envDeploymentEnvironment
3842
39- const additionalSpanProcessors = config . console ? [ new SimpleSpanProcessor ( new LogfireCloudflareConsoleSpanExporter ( ) ) ] : [ ]
43+ const additionalSpanProcessors = config . additionalSpanProcessors ?? [ ]
44+
45+ if ( config . console ) {
46+ additionalSpanProcessors . push ( new SimpleSpanProcessor ( new LogfireCloudflareConsoleSpanExporter ( ) ) )
47+ }
4048
4149 return Object . assign ( { } , config , {
4250 additionalSpanProcessors,
0 commit comments