Send OpenLIT traces and metrics to Zerobus Ingest
For the Zerobus Ingest endpoints, the tables, the grants, and the column reference, see Configure OpenTelemetry (OTLP) clients to send data to Unity Catalog and OpenTelemetry table reference for Zerobus Ingest. The token handling comes from the oauth2client extension in the OpenTelemetry Collector Contrib distribution. For what OpenLIT instruments and how to configure it, see the OpenLIT repository and its Python SDK README.
Maintained by: the OpenLIT open-source project, in the openlit/openlit repository.
OpenLIT is an Apache-2.0 project. Its Python SDK instruments large language model (LLM) providers and frameworks in your application with one openlit.init() call, and it exports traces and metrics over the OpenTelemetry Protocol (OTLP). This page shows how to send those traces and metrics to Zerobus Ingest through the OpenTelemetry Collector. The application sends OTLP to the Collector on the same host. The Collector's oauth2client extension gets an OAuth token from a Databricks service principal and refreshes it before it expires.
When to use this path
Use this path when any of these apply:
- Your LLM application runs for longer than one hour, so a static token would expire during the run.
- You want application processes to send telemetry without OAuth code or credentials.
- You send traces and metrics from OpenLIT and want them in Delta tables.
This page covers traces and metrics only. OpenLIT's events, which are exported as logs, are off in this setup. See Troubleshooting.
How it works
OpenLIT's openlit.init() call sets up OpenTelemetry tracing and metrics and instruments the supported frameworks that are installed. It exports over OTLP/HTTP to the endpoint you pass as otlp_endpoint. In this setup, that endpoint is the Collector's HTTP receiver on 127.0.0.1:4318.
The Collector has one OTLP receiver and two pipelines, one for traces and one for metrics. Each pipeline exports through its own exporter to its own table.
Each exporter has its own oauth2client extension. The extension's token is scoped to the table that exporter writes to. The x-databricks-zerobus-table-name header names the target table, and each request targets a single table.
The Collector holds accepted telemetry in memory until it exports it. If the Collector stops or can't reach Zerobus Ingest, the telemetry in its queues and the telemetry OpenLIT sends while the Collector is down can be lost. See Troubleshooting.
Requirements
To send OpenLIT traces and metrics to Zerobus Ingest, you need the following:
- Target tables that meet the Table requirements. For the endpoint and the workspace URL, see Get your workspace URL and Zerobus Ingest endpoint.
- Permission to create tables in the schema, and access to Databricks SQL to run the table statements.
- A Databricks service principal with an OAuth secret that has
all-apisaccess, and the Workspace access entitlement. The Collector requestsall-apis, so a secret with narrower scopes can't authenticate. Scopes can't change after a secret is created, so generate a new secret if the existing one is narrower. The Databricks service principal needsUSE CATALOGon the catalog,USE SCHEMAon the schema, andMODIFYandSELECTon each of the two tables.ALL PRIVILEGESisn't enough. See Create a service principal and grant permissions and Scoped OAuth secrets. - A Databricks Runtime version with variant shredding support, to create and query these tables. The table definitions in Create the tables and grant access turn on variant shredding. See Use variant shredding to optimize performance for the minimum version.
- The OpenTelemetry Collector Contrib distribution, version 0.165.0. The
oauth2clientextension is in Contrib, not in the core distribution. - Python 3.11 and above, with
pip, in the environment where the application runs.
Create the tables and grant access
In Databricks SQL, run the following two CREATE TABLE statements, after you replace <catalog>.<schema>.<prefix> with your catalog, schema, and table prefix. The tables are <prefix>_otel_spans and <prefix>_otel_metrics. These are the table definitions from Configure OpenTelemetry (OTLP) clients. OpenLIT also has a logs signal, but this page doesn't create a logs table.
CREATE TABLE <catalog>.<schema>.<prefix>_otel_spans (
record_id STRING,
time TIMESTAMP,
date DATE,
service_name STRING,
trace_id STRING,
span_id STRING,
trace_state STRING,
parent_span_id STRING,
flags INT,
name STRING,
kind STRING,
start_time_unix_nano LONG,
end_time_unix_nano LONG,
attributes VARIANT,
dropped_attributes_count INT,
events ARRAY<STRUCT<
time_unix_nano: LONG,
name: STRING,
attributes: VARIANT,
dropped_attributes_count: INT
>>,
dropped_events_count INT,
links ARRAY<STRUCT<
trace_id: STRING,
span_id: STRING,
trace_state: STRING,
attributes: VARIANT,
dropped_attributes_count: INT,
flags: INT
>>,
dropped_links_count INT,
status STRUCT<
message: STRING,
code: STRING
>,
resource STRUCT<
attributes: VARIANT,
dropped_attributes_count: INT
>,
resource_schema_url STRING,
instrumentation_scope STRUCT<
name: STRING,
version: STRING,
attributes: VARIANT,
dropped_attributes_count: INT
>,
span_schema_url STRING
) USING DELTA
CLUSTER BY (time, service_name, trace_id)
TBLPROPERTIES (
'otel.schemaVersion' = 'v2',
'delta.checkpointPolicy' = 'classic',
'delta.enableVariantShredding' = 'true', -- optional
'delta.feature.variantShredding' = 'supported', -- optional
'delta.feature.variantType' = 'supported' -- optional
);
CREATE TABLE <catalog>.<schema>.<prefix>_otel_metrics (
record_id STRING,
time TIMESTAMP,
date DATE,
service_name STRING,
start_time_unix_nano LONG,
time_unix_nano LONG,
name STRING,
description STRING,
unit STRING,
metric_type STRING,
gauge STRUCT<
value: DOUBLE,
exemplars: ARRAY<STRUCT<
time_unix_nano: LONG,
value: DOUBLE,
span_id: STRING,
trace_id: STRING,
filtered_attributes: VARIANT
>>,
attributes: VARIANT,
flags: INT
>,
sum STRUCT<
value: DOUBLE,
exemplars: ARRAY<STRUCT<
time_unix_nano: LONG,
value: DOUBLE,
span_id: STRING,
trace_id: STRING,
filtered_attributes: VARIANT
>>,
attributes: VARIANT,
flags: INT,
aggregation_temporality: STRING,
is_monotonic: BOOLEAN
>,
histogram STRUCT<
count: LONG,
sum: DOUBLE,
bucket_counts: ARRAY<LONG>,
explicit_bounds: ARRAY<DOUBLE>,
exemplars: ARRAY<STRUCT<
time_unix_nano: LONG,
value: DOUBLE,
span_id: STRING,
trace_id: STRING,
filtered_attributes: VARIANT
>>,
attributes: VARIANT,
flags: INT,
min: DOUBLE,
max: DOUBLE,
aggregation_temporality: STRING
>,
exponential_histogram STRUCT<
attributes: VARIANT,
count: LONG,
sum: DOUBLE,
scale: INT,
zero_count: LONG,
positive_bucket: STRUCT<
offset: INT,
bucket_counts: ARRAY<LONG>
>,
negative_bucket: STRUCT<
offset: INT,
bucket_counts: ARRAY<LONG>
>,
flags: INT,
exemplars: ARRAY<STRUCT<
time_unix_nano: LONG,
value: DOUBLE,
span_id: STRING,
trace_id: STRING,
filtered_attributes: VARIANT
>>,
min: DOUBLE,
max: DOUBLE,
zero_threshold: DOUBLE,
aggregation_temporality: STRING
>,
summary STRUCT<
count: LONG,
sum: DOUBLE,
quantile_values: ARRAY<STRUCT<
quantile: DOUBLE,
value: DOUBLE
>>,
attributes: VARIANT,
flags: INT
>,
metadata VARIANT,
resource STRUCT<
attributes: VARIANT,
dropped_attributes_count: INT
>,
resource_schema_url STRING,
instrumentation_scope STRUCT<
name: STRING,
version: STRING,
attributes: VARIANT,
dropped_attributes_count: INT
>,
metric_schema_url STRING
) USING DELTA
CLUSTER BY (time, service_name)
TBLPROPERTIES (
'otel.schemaVersion' = 'v2',
'delta.checkpointPolicy' = 'classic',
'delta.enableVariantShredding' = 'true', -- optional
'delta.feature.variantShredding' = 'supported', -- optional
'delta.feature.variantType' = 'supported' -- optional
);
Then grant the Databricks service principal access. Replace <service-principal-uuid> with its client ID:
GRANT USE CATALOG ON CATALOG <catalog> TO `<service-principal-uuid>`;
GRANT USE SCHEMA ON SCHEMA <catalog>.<schema> TO `<service-principal-uuid>`;
GRANT MODIFY, SELECT ON TABLE <catalog>.<schema>.<prefix>_otel_spans TO `<service-principal-uuid>`;
GRANT MODIFY, SELECT ON TABLE <catalog>.<schema>.<prefix>_otel_metrics TO `<service-principal-uuid>`;
Install the Collector Contrib
Download the Contrib archive for your platform from the OpenTelemetry Collector releases page, along with the .sha256 file published next to it. Before you extract the archive, compare its SHA-256 hash with the hash in that file. Then extract the archive and check the binary:
tar -xzf otelcol-contrib_0.165.0_linux_amd64.tar.gz
./otelcol-contrib --version
./otelcol-contrib components | grep oauth2client
Create the Collector configuration
Set these variables in the shell where you start the Collector:
Variable | Value |
|---|---|
| The Databricks service principal's client ID. |
| The Databricks service principal's OAuth secret. The Collector reads it from the environment, so it stays out of the file. |
| Your workspace URL, |
| Your workspace ID, |
| Your Zerobus Ingest endpoint host, without |
| The catalog and schema from Create the tables and grant access. |
| The prefix from Create the tables and grant access. |
To find your values, see Get your workspace URL and Zerobus Ingest endpoint.
Your endpoint host is <workspace-id>.zerobus.<region>.gcp.databricks.com.
Save this configuration as collector.yaml. It has one oauth2client extension and one otlp_grpc exporter for each table, and one pipeline for each signal:
# OpenTelemetry Collector configuration for Zerobus Ingest. Set the ${env:...} values in the environment.
# Put no secrets in this file. Each signal has its own oauth2client extension and exporter.
extensions:
oauth2client/spans:
client_id: ${env:DATABRICKS_CLIENT_ID}
client_secret: ${env:DATABRICKS_CLIENT_SECRET}
token_url: ${env:DATABRICKS_WORKSPACE_URL}/oidc/v1/token
scopes: ['all-apis']
endpoint_params:
resource: 'api://databricks/workspaces/${env:WORKSPACE_ID}/zerobusDirectWriteApi'
authorization_details:
- '[{"type":"unity_catalog_privileges","privileges":["USE CATALOG"],"object_type":"CATALOG","object_full_path":"${env:CATALOG}"},{"type":"unity_catalog_privileges","privileges":["USE SCHEMA"],"object_type":"SCHEMA","object_full_path":"${env:CATALOG}.${env:SCHEMA}"},{"type":"unity_catalog_privileges","privileges":["SELECT","MODIFY"],"object_type":"TABLE","object_full_path":"${env:CATALOG}.${env:SCHEMA}.${env:TABLE_PREFIX}_otel_spans"}]'
oauth2client/metrics:
client_id: ${env:DATABRICKS_CLIENT_ID}
client_secret: ${env:DATABRICKS_CLIENT_SECRET}
token_url: ${env:DATABRICKS_WORKSPACE_URL}/oidc/v1/token
scopes: ['all-apis']
endpoint_params:
resource: 'api://databricks/workspaces/${env:WORKSPACE_ID}/zerobusDirectWriteApi'
authorization_details:
- '[{"type":"unity_catalog_privileges","privileges":["USE CATALOG"],"object_type":"CATALOG","object_full_path":"${env:CATALOG}"},{"type":"unity_catalog_privileges","privileges":["USE SCHEMA"],"object_type":"SCHEMA","object_full_path":"${env:CATALOG}.${env:SCHEMA}"},{"type":"unity_catalog_privileges","privileges":["SELECT","MODIFY"],"object_type":"TABLE","object_full_path":"${env:CATALOG}.${env:SCHEMA}.${env:TABLE_PREFIX}_otel_metrics"}]'
exporters:
otlp_grpc/spans:
endpoint: ${env:ZEROBUS_ENDPOINT}:443
auth:
authenticator: oauth2client/spans
headers:
x-databricks-zerobus-table-name: '${env:CATALOG}.${env:SCHEMA}.${env:TABLE_PREFIX}_otel_spans'
otlp_grpc/metrics:
endpoint: ${env:ZEROBUS_ENDPOINT}:443
auth:
authenticator: oauth2client/metrics
headers:
x-databricks-zerobus-table-name: '${env:CATALOG}.${env:SCHEMA}.${env:TABLE_PREFIX}_otel_metrics'
receivers:
otlp:
protocols:
grpc:
endpoint: 127.0.0.1:4317
http:
endpoint: 127.0.0.1:4318
processors:
batch:
timeout: 5s
send_batch_size: 10
service:
extensions: [oauth2client/spans, oauth2client/metrics]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp_grpc/spans]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlp_grpc/metrics]
The receiver listens on 127.0.0.1, so only applications on the same host can send to it.
Start the Collector
Start the Collector with the collector.yaml configuration file:
./otelcol-contrib --config collector.yaml
When the log shows Everything is ready. Begin running and processing data., the receivers accept OTLP on 127.0.0.1:4317 (gRPC) and 127.0.0.1:4318 (HTTP).
Install OpenLIT and point it at the Collector
Install the pinned packages in the application's environment:
pip install openlit==1.45.0 langchain-core==1.8.2
Call openlit.init() before you create the LLM chain, and point otlp_endpoint at the Collector's HTTP receiver:
import openlit
from langchain_core.language_models.fake_chat_models import FakeListChatModel
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
openlit.init(
otlp_endpoint="http://127.0.0.1:4318",
application_name="openlit-dice-app",
environment="demo",
disable_events=True,
)
model = FakeListChatModel(responses=["The host rolls a six-sided die: 5. Lucky roll!"])
prompt = ChatPromptTemplate.from_messages(
[
("system", "You are the host of a dice game."),
("user", "Roll a {sides}-sided die for {player}."),
]
)
chain = prompt | model | StrOutputParser()
print(chain.invoke({"sides": 6, "player": "demo"}))
The snippet uses a fake chat model, so it runs without a model API key. In your application, use your provider's chat model instead. OpenLIT instruments the call the same way. The application_name value becomes service_name in the tables. The disable_events=True argument keeps OpenLIT's logs off.
OpenLIT 1.45.0 passes otlp_endpoint to its exporters through the OTEL_EXPORTER_OTLP_ENDPOINT environment variable, and it also reads other standard OpenTelemetry variables that change where or how it sends a signal:
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTandOTEL_EXPORTER_OTLP_METRICS_ENDPOINTtake precedence overOTEL_EXPORTER_OTLP_ENDPOINT.OTEL_TRACES_EXPORTERandOTEL_METRICS_EXPORTERchoose the exporter for each signal. With a value ofconsoleornone, that signal doesn't go to the Collector.OTEL_EXPORTER_OTLP_PROTOCOL=grpcswitches OpenLIT to its gRPC exporters.
In the shell where you run the application, unset the five variables in the preceding list, so that both signals go to the Collector's HTTP receiver:
unset OTEL_EXPORTER_OTLP_TRACES_ENDPOINT OTEL_EXPORTER_OTLP_METRICS_ENDPOINT OTEL_TRACES_EXPORTER OTEL_METRICS_EXPORTER OTEL_EXPORTER_OTLP_PROTOCOL
Save the Python snippet as app.py and run it in the same shell with python app.py. Each call produces one span.
Query the tables
Spans appear about five seconds after each call, which is the batch timeout in this configuration. Metrics appear on the next export interval, which is 60 seconds by default:
SELECT time, service_name, name, kind FROM <catalog>.<schema>.<prefix>_otel_spans ORDER BY time DESC LIMIT 10;
SELECT name, histogram.count AS calls, histogram.sum AS total FROM <catalog>.<schema>.<prefix>_otel_metrics WHERE name = 'gen_ai.client.operation.duration';
Each LLM call has one span named chat followed by the model name, for example chat FakeListChatModel, with the gen_ai.* attributes that OpenLIT records. The metrics table has the gen_ai.client.* and gen_ai.server.* histograms.
Troubleshooting
Symptom | Cause | Fix |
|---|---|---|
The application prints | OpenLIT's events are on, so it exports logs, but this configuration has no logs pipeline. | Pass |
The application prints | The Collector isn't running, or the application can't reach its HTTP receiver. The spans in a batch that the application gives up on are lost. | Check that the Collector is running and that |
The Collector logs | A span in the request has no start time. Zerobus Ingest drops that span and keeps the other spans in the request. | Set a start time on every span. OpenLIT's own spans have one. |
The application gets | A span has a trace ID that isn't 16 bytes. The Collector's HTTP receiver rejects the whole request, including the valid spans in it. | Send only valid trace IDs. OpenLIT's own spans have valid IDs. |
Metrics don't appear after the first calls | Metrics are exported on a 60-second interval, not per call. | Wait for the next export, or stop the application so the SDK flushes its metrics. |
Additional resources
- Send data to Zerobus Ingest via the OpenTelemetry Collector: the Collector setup for logs, metrics, and traces from an OpenTelemetry SDK, with one table for each signal.
- Configure OpenTelemetry (OTLP) clients to send data to Unity Catalog: the endpoints, the headers, and the static-token quick start.
- OpenTelemetry table reference for Zerobus Ingest: the columns in each table.
- Zerobus Ingest error handling: the error codes Zerobus Ingest returns.
- OpenLIT Python SDK: the
openlit.init()options and the supported integrations. - OpenTelemetry Collector configuration: the receivers, processors, exporters, and extensions this page uses.