spakky-opentelemetry¶
OpenTelemetry SDK 브릿지 — Spakky 트레이싱을 OpenTelemetry로 연결
브릿지¶
spakky.plugins.opentelemetry.bridge
¶
LogContextBridge — optional trace-to-logging context synchronization.
LogContextBridge(binder=None)
¶
Synchronizes TraceContext fields into LogContext.
When an ILogContextBinder is available (i.e., spakky-logging is
installed and registered), sync() binds the current trace_id
and span_id into the structured logging context.
When no binder is available, all operations are no-ops.
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/bridge.py
sync()
¶
Bind current TraceContext's trace_id/span_id into LogContext.
If no ILogContextBinder was injected, this is a no-op.
If no TraceContext is active, unbinds trace fields.
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/bridge.py
options: show_root_heading: false
Propagator¶
spakky.plugins.opentelemetry.propagator
¶
OTelTracePropagator — OpenTelemetry SDK bridge for ITracePropagator.
OTelTracePropagator()
¶
Bases: ITracePropagator
Bridges Spakky's TraceContext with OpenTelemetry's context propagation.
Converts between Spakky's contextvars-based TraceContext and OTel's Context system using NonRecordingSpan for lightweight propagation.
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/propagator.py
inject(carrier)
¶
Read the ambient TraceContext and write it into the carrier.
Converts Spakky's TraceContext to an OTel Context, then delegates to the W3C TraceContext propagator for header serialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
carrier
|
dict[str, str]
|
Mutable header dictionary. |
required |
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/propagator.py
extract(carrier)
¶
Reconstruct a TraceContext from the carrier.
Delegates to the OTel propagator for header parsing, then converts the resulting OTel SpanContext back to Spakky's TraceContext.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
carrier
|
dict[str, str]
|
Read-only header dictionary. |
required |
Returns:
| Type | Description |
|---|---|
TraceContext | None
|
The restored TraceContext, or None if headers are missing/invalid. |
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/propagator.py
fields()
¶
Return the header field names used by this propagator.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of header names (traceparent, tracestate). |
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/propagator.py
options: show_root_heading: false
후처리기¶
spakky.plugins.opentelemetry.post_processor
¶
Post-processor that configures OpenTelemetry SDK and replaces W3CTracePropagator.
OTelSetupPostProcessor()
¶
Bases: IPostProcessor, IContainerAware
Initializes OTel TracerProvider and replaces W3CTracePropagator.
On first post_process call, configures the global TracerProvider
with the user's chosen exporter. For every pod that is an instance of
W3CTracePropagator, returns an OTelTracePropagator instead.
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/post_processor.py
post_process(pod)
¶
Configure TracerProvider on first call; replace W3CTracePropagator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
object
|
The Pod instance being processed. |
required |
Returns:
| Type | Description |
|---|---|
object
|
OTelTracePropagator if pod is W3CTracePropagator, else pod unchanged. |
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/post_processor.py
options: show_root_heading: false
설정¶
spakky.plugins.opentelemetry.config
¶
OpenTelemetry plugin configuration.
ExporterType
¶
Bases: StrEnum
Supported span exporter types.
OpenTelemetryConfig()
¶
Bases: BaseSettings
Configuration for the OpenTelemetry SDK bridge.
Attributes:
| Name | Type | Description |
|---|---|---|
service_name |
str
|
OTel service name for resource identification. |
exporter_type |
ExporterType
|
Span exporter backend (otlp, console, none). |
exporter_endpoint |
str
|
OTLP collector endpoint URL. |
sample_rate |
Annotated[float, Field(ge=0.0, le=1.0)]
|
Trace sampling rate (0.0 to 1.0). |
Source code in plugins/spakky-opentelemetry/src/spakky/plugins/opentelemetry/config.py
options: show_root_heading: false
에러¶
spakky.plugins.opentelemetry.error
¶
options: show_root_heading: false