OpenTelemetry SDK bridge for Spakky Framework
Project description
spakky-opentelemetry
OpenTelemetry SDK bridge for Spakky Framework.
spakky-tracing이 제공하는 ITracePropagator 인터페이스의 OpenTelemetry 구현체입니다. 플러그인을 설치하면 OTelSetupPostProcessor가 컨테이너의 W3CTracePropagator를 OTelTracePropagator로 자동 교체하여, OTel 백엔드(Jaeger, Grafana Tempo 등)와 연동합니다.
spakky-tracing과의 관계
spakky-tracing은 TraceContext와 ITracePropagator 추상화를 제공하고, 기본 구현체로 W3CTracePropagator를 등록합니다. spakky-opentelemetry는 이 기본 구현체를 런타임에 교체합니다:
OTelSetupPostProcessor(@Order(0))가 Pod 후처리 단계에서W3CTracePropagator인스턴스를 감지- 해당 인스턴스를
OTelTracePropagator로 교체하여 반환 - 동시에 OTel
TracerProvider를 설정 (exporter, sampler, resource)
따라서 spakky-tracing만 설치하면 순수 W3C TraceContext 전파가 동작하고, spakky-opentelemetry를 추가하면 OTel SDK 기반 전파로 업그레이드됩니다.
Installation
pip install spakky-opentelemetry
OTLP exporter 사용 시:
pip install spakky-opentelemetry[otlp]
spakky-logging 브릿지 사용 시:
pip install spakky-opentelemetry[logging]
Features
| 컴포넌트 | 역할 |
|---|---|
OpenTelemetryConfig |
@Configuration — 환경변수 기반 OTel SDK 설정 |
OTelSetupPostProcessor |
IPostProcessor — TracerProvider 초기화 및 W3CTracePropagator 교체 |
OTelTracePropagator |
ITracePropagator 구현 — OTel SDK의 TraceContextTextMapPropagator 브릿지 |
LogContextBridge |
TraceContext의 trace_id/span_id를 spakky-logging의 LogContext에 동기화 (optional) |
ExporterType |
StrEnum — 지원 exporter 타입 (otlp, console, none) |
Configuration
환경변수로 설정합니다 (OpenTelemetryConfig, env prefix: SPAKKY_OTEL_):
| 환경변수 | 기본값 | 설명 |
|---|---|---|
SPAKKY_OTEL_SERVICE_NAME |
spakky-service |
OTel 서비스 이름 |
SPAKKY_OTEL_EXPORTER_TYPE |
otlp |
스팬 exporter (otlp, console, none) |
SPAKKY_OTEL_EXPORTER_ENDPOINT |
http://localhost:4317 |
OTLP collector 엔드포인트 |
SPAKKY_OTEL_SAMPLE_RATE |
1.0 |
트레이스 샘플링 비율 (0.0~1.0) |
Usage
플러그인은 spakky.plugins 엔트리 포인트로 자동 등록됩니다. SpakkyApplication.load_plugins()를 호출하면 자동으로 활성화됩니다.
from spakky.core.application.application import SpakkyApplication
from spakky.core.application.application_context import ApplicationContext
app = (
SpakkyApplication(ApplicationContext())
.load_plugins() # spakky-opentelemetry 자동 로드
.scan(my_module)
.start()
)
LogContext 브릿지
spakky-logging이 설치되어 있으면 LogContextBridge.sync()로 trace_id/span_id를 로그 컨텍스트에 바인딩할 수 있습니다. spakky-logging이 없으면 no-op으로 동작합니다:
from spakky.plugins.opentelemetry.bridge import LogContextBridge
# TraceContext 설정 후
LogContextBridge.sync() # LogContext에 trace_id, span_id 자동 바인딩
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spakky_opentelemetry-6.4.0.tar.gz.
File metadata
- Download URL: spakky_opentelemetry-6.4.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b6f82cee6b75ad85b426982c33e0a4bfba0a5b446e85c1f9cb19c44f3d3578d
|
|
| MD5 |
a6b395445cc7af53d9c37bb634ac2e15
|
|
| BLAKE2b-256 |
4c8672beab1ee51682fa3946057b668bb033e9cc04f11fcd67c0e952bdb10f79
|
Provenance
The following attestation bundles were made for spakky_opentelemetry-6.4.0.tar.gz:
Publisher:
release.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_opentelemetry-6.4.0.tar.gz -
Subject digest:
5b6f82cee6b75ad85b426982c33e0a4bfba0a5b446e85c1f9cb19c44f3d3578d - Sigstore transparency entry: 1435903982
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spakky_opentelemetry-6.4.0-py3-none-any.whl.
File metadata
- Download URL: spakky_opentelemetry-6.4.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c32b60289646850bf4fcc00cf27a0154e87c5dbde3cdc0572657fdff73cdce45
|
|
| MD5 |
e7e42ad4aefb57cbdc4608776b13bdc6
|
|
| BLAKE2b-256 |
055f9fbe89ca3e00ed2de4e385dea1b20b43e394c6ab7790d60e14a1d6813094
|
Provenance
The following attestation bundles were made for spakky_opentelemetry-6.4.0-py3-none-any.whl:
Publisher:
release.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_opentelemetry-6.4.0-py3-none-any.whl -
Subject digest:
c32b60289646850bf4fcc00cf27a0154e87c5dbde3cdc0572657fdff73cdce45 - Sigstore transparency entry: 1435904044
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Trigger Event:
workflow_dispatch
-
Statement type: