# OTEL Trace Ingestion

[OpenTellemetry](https://opentelemetry.io/docs/what-is-opentelemetry/) (OTEL) Trace Ingestion allows for the richest data to be uploaded to your Project, but requires some off-platform coding and does not support backfilling data.

{% hint style="warning" %}
OTEL Trace Ingestion needs to be enabled during [Deployment](https://docs.dbnl.com/v0.27.x/platform/deployment) so that the required Clickhouse database is provisioned and initialized.
{% endhint %}

The following fields are required regardless of which ingestion method you are using:

* `input`: The text input to the LLM as a `string`.
* `output`: The text response from the LLM as a `string`.
* `timestamp`: The UTC timecode associated with the LLM call as a `timestamptz`.

{% hint style="info" %}
See the [DBNL Semantic Convention](https://docs.dbnl.com/v0.27.x/configuration/dbnl-semantic-convention) for other semantically recognized fields. Using these naming conventions will allow DBNL to map semantic meaning to those columns and provide better [Dashboards](https://docs.dbnl.com/v0.27.x/workflow/dashboards) and [Insights](https://docs.dbnl.com/v0.27.x/workflow/insights).
{% endhint %}

## Example Trace Publishing Code

Embed the following code into your production AI product wherever you would normally capture traces. For more examples see the [OpenTelemetry docs](https://opentelemetry.io/docs/languages/python/getting-started/).

```python
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import BatchSpanProcessor

tracer_provider = trace_sdk.TracerProvider()
trace_api.set_tracer_provider(tracer_provider)
tracer_provider.add_span_processor(
    BatchSpanProcessor(
        OTLPSpanExporter(
            endpoint="https://api.dev.dbnl.com/otel/v1/traces",
            headers={
                "Authorization": "Bearer API_TOKEN",
                "x-dbnl-project-id": "PROJECT_ID",
            },
        )
    )
)
```
