|
| 1 | +# OpenTelemetry Traces |
| 2 | + |
| 3 | +Trackio can receive OpenTelemetry trace data over OTLP/HTTP and show it in the |
| 4 | +dashboard's **Traces** tab. This is useful for agent and LLM frameworks that |
| 5 | +already emit OpenTelemetry or OpenInference spans, such as smolagents through |
| 6 | +`openinference-instrumentation-smolagents`. |
| 7 | + |
| 8 | +This is a minimal v1 receiver: |
| 9 | + |
| 10 | +- supported endpoint: `POST /otel/v1/traces` |
| 11 | +- supported encoding: OTLP protobuf (`application/x-protobuf`) |
| 12 | +- supported signal: traces |
| 13 | +- storage: each incoming span is converted to a `trackio.Trace` log entry |
| 14 | + |
| 15 | +## Start Trackio |
| 16 | + |
| 17 | +Launch a writable Trackio dashboard: |
| 18 | + |
| 19 | +```bash |
| 20 | +trackio show |
| 21 | +``` |
| 22 | + |
| 23 | +Use the write-access URL or token printed by the server. For a local server, |
| 24 | +OTLP requests must include the same write token as normal remote logging. |
| 25 | + |
| 26 | +## Configure an OTLP Exporter |
| 27 | + |
| 28 | +Point your OpenTelemetry exporter at Trackio: |
| 29 | + |
| 30 | +```bash |
| 31 | +export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://localhost:7860/otel/v1/traces" |
| 32 | +export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf" |
| 33 | +export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-trackio-write-token=<write-token>" |
| 34 | +``` |
| 35 | + |
| 36 | +Set the Trackio project and run using OpenTelemetry resource attributes: |
| 37 | + |
| 38 | +```python |
| 39 | +from opentelemetry.sdk.resources import Resource |
| 40 | +from opentelemetry.sdk.trace import TracerProvider |
| 41 | + |
| 42 | +provider = TracerProvider( |
| 43 | + resource=Resource( |
| 44 | + { |
| 45 | + "trackio.project": "my-project", |
| 46 | + "trackio.run": "agent-run", |
| 47 | + "service.name": "smolagents", |
| 48 | + } |
| 49 | + ) |
| 50 | +) |
| 51 | +``` |
| 52 | + |
| 53 | +If `trackio.project` is not set, Trackio uses the `project` query parameter if |
| 54 | +present, then falls back to `otel-traces`. If `trackio.run` is not set, Trackio |
| 55 | +uses `service.name`, then falls back to `otel`. |
| 56 | + |
| 57 | +## Example: smolagents with OpenInference |
| 58 | + |
| 59 | +```bash |
| 60 | +pip install smolagents opentelemetry-sdk opentelemetry-exporter-otlp-proto-http openinference-instrumentation-smolagents |
| 61 | +``` |
| 62 | + |
| 63 | +```python |
| 64 | +from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter |
| 65 | +from opentelemetry.sdk.resources import Resource |
| 66 | +from opentelemetry.sdk.trace import TracerProvider |
| 67 | +from opentelemetry.sdk.trace.export import BatchSpanProcessor |
| 68 | +from openinference.instrumentation.smolagents import SmolagentsInstrumentor |
| 69 | + |
| 70 | +provider = TracerProvider( |
| 71 | + resource=Resource( |
| 72 | + { |
| 73 | + "trackio.project": "agent-debugging", |
| 74 | + "trackio.run": "smolagents", |
| 75 | + "service.name": "smolagents", |
| 76 | + } |
| 77 | + ) |
| 78 | +) |
| 79 | +provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) |
| 80 | +SmolagentsInstrumentor().instrument(tracer_provider=provider) |
| 81 | + |
| 82 | +# Run your smolagents application normally. Spans will appear in Trackio. |
| 83 | +``` |
| 84 | + |
| 85 | +## Notes |
| 86 | + |
| 87 | +Trackio preserves the raw span attributes in trace metadata and maps common |
| 88 | +OpenInference fields such as `input.value`, `output.value`, and indexed |
| 89 | +`llm.input_messages.*` / `llm.output_messages.*` attributes into conversational |
| 90 | +messages for the Traces tab. |
| 91 | + |
| 92 | +Runnable examples are available in `examples/otel-basic-mvp.py` and |
| 93 | +`examples/otel-smolagents-integration.py`. |
0 commit comments