Obtrace Python SDK
Project description
obtrace-sdk-python
Python backend SDK for Obtrace telemetry transport and instrumentation.
Scope
- OTLP logs/traces/metrics transport
- Context propagation
- HTTP instrumentation (requests/httpx)
- Framework helpers (FastAPI, Flask)
Design Principle
SDK is thin/dumb.
- No business logic authority in client SDK.
- Policy and product logic are server-side.
Install
pip install obtrace-sdk-python
Configuration
Required:
api_keyingest_base_urlservice_name
Optional (auto-resolved from API key on the server side):
tenant_idproject_idapp_idenvservice_version
Quickstart
Simplified setup
The API key resolves tenant_id, project_id, app_id, and env automatically on the server side, so only three fields are needed:
from obtrace_sdk import ObtraceClient, ObtraceConfig
client = ObtraceClient(
ObtraceConfig(
api_key="obt_live_...",
ingest_base_url="https://ingest.obtrace.io",
service_name="my-service",
)
)
Full configuration
For advanced use cases you can override the resolved values explicitly:
from obtrace_sdk import ObtraceClient, ObtraceConfig, SemanticMetrics
client = ObtraceClient(
ObtraceConfig(
api_key="<API_KEY>",
ingest_base_url="https://inject.obtrace.ai",
service_name="python-api",
env="prod",
)
)
client.log("info", "started")
client.metric(SemanticMetrics.RUNTIME_CPU_UTILIZATION, 0.41)
client.span(
"checkout.charge",
attrs={
"feature.name": "checkout",
"payment.provider": "stripe",
},
)
client.flush()
Canonical metrics and custom spans
- Use
SemanticMetricsfor the product-wide metric catalog. - Custom spans use
client.span(name, attrs=...). - Keep free-form metric names only for truly product-specific signals that are not part of the shared catalog.
Frameworks and HTTP
- Framework helpers: FastAPI and Flask
- HTTP instrumentation:
requestsandhttpx - Reference docs:
docs/frameworks.mddocs/http-instrumentation.md
Production Hardening
- Keep
api_keyonly in server-side secret storage. - Use one key per environment and rotate periodically.
- Keep fail-open behavior (telemetry must not break request flow).
- Validate ingestion after deploy using Query Gateway and ClickHouse checks.
Troubleshooting
- No telemetry: validate
ingest_base_url, API key, and egress connectivity. - Missing correlation: ensure propagation headers are injected on outbound HTTP.
- Short-lived workers: call
flush()before process exit.
Documentation
- Docs index:
docs/index.md - LLM context file:
llm.txt - MCP metadata:
mcp.json
Reference
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 obtrace_sdk_python-1.0.2.tar.gz.
File metadata
- Download URL: obtrace_sdk_python-1.0.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1227bfa5e3a6c3a25be41390ab6cca00ae900bbc8d6908b7300f560001e19ef9
|
|
| MD5 |
0da26dc13bc65e36eeef1134cd0dc11e
|
|
| BLAKE2b-256 |
44e49c24421d22e6a9a46e133276326710b9b604daa689059dc5864dc6f05cdb
|
File details
Details for the file obtrace_sdk_python-1.0.2-py3-none-any.whl.
File metadata
- Download URL: obtrace_sdk_python-1.0.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8562d3212aeaa8f6e24b778d426c9b8335ce65651265458963325c9acf83a71f
|
|
| MD5 |
7ba9c4fba7f22f254d4ab9b132b72cb3
|
|
| BLAKE2b-256 |
76b2331a75b5ff00b76f84be113d1d9f19ac3b88d0a4d5a1dac5ced0fb603da5
|