Thin SDK, smart collector. The SDK does minimal work in the hot path; everything heavy runs in the OpenTelemetry Collector.
- Generates a UUIDv7
run_idper event - Sets seven W3C Baggage keys on the active OTel context
- Records token counts as span attributes
- Exports spans via OTLP/HTTP
Target overhead: under 0.5 ms per request.
- Cost calculation from token counts
- Vendor normalization
- Cardinality management
- Aggregation and sampling
- Belt-and-suspenders PII regex (SDK already scrubs captured content in-process — see
botanu/sdk/pii.py)
BotanuConfig— configuration dataclass. See Configuration.RunContext— run metadata + serialization. See Run Context.RunContextEnricher— OTel SpanProcessor that reads baggage and stamps span attributes.- Tracking helpers:
track_llm_call,track_db_operation,track_storage_operation,track_messaging_operation.
from opentelemetry import trace
from botanu.processors.enricher import RunContextEnricher
provider = trace.get_tracer_provider()
provider.add_span_processor(RunContextEnricher())If you already have an OTel setup, the SDK detects it and adds itself alongside. See Coexisting with existing OTel / Datadog.