Repository navigation
Add optional OpenTelemetry tracing and request metrics - #44
mikelangmayr wants to merge 3 commits into
Conversation
|
|
||
| tracer_provider = TracerProvider(resource=resource) | ||
| tracer_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter(**timeout))) | ||
| trace.set_tracer_provider(tracer_provider) |
There was a problem hiding this comment.
I think OpenTelemetry keeps one global tracer provider per process, and trace.set_tracer_provider() is done the first time when starting the process
We'll probably need to make sure the tracer provider is reinstantiated if the process has to be restarted or stop/start
There was a problem hiding this comment.
Confirmed: a stop/start in one process dropped every span after the restart. stop now only flushes; the SDK is installed once and lives until process exit. test_restarted_daemon_keeps_exporting covers it.
| instruments = _instruments | ||
| if instruments is None: | ||
| return _UNTRACED | ||
| return Call.start(instruments, name, instruments.trace.SpanKind.INTERNAL, {}) |
There was a problem hiding this comment.
Call.start and _Instruments.incoming use the global propagator (opentelemetry.propagate), so they assume it reads and writes traceparent / tracestate. That's only true if W3C is among the configured propagators. If a user sets OpenTelemetry SDK to use the B3 Single Header format inject() writes a b3 key instead, the envelope goes out with traceparent: null I believe
In bamboo the envelope fields are W3C Trace Context by spec, so the format shouldn't depend on deployment config. What about using the TraceContextTextMapPropagator() directly for the envelope?
There was a problem hiding this comment.
Agreed, traceparent went out as null with OTEL_PROPAGATORS=baggage. The envelope now uses TraceContextTextMapPropagator directly; test_envelope_context_ignores_the_global_propagator covers it.
otelextra; libby imports OpenTelemetry only when it is installed and an OTLP endpoint is settraceparent; producer and consumer spans for publisherror.typeon failuresLibbyDaemonturns export on atstartand flushes atstop; the SDK lives for the processtrace_idandspan_idappended