Skip to main content

Send OpenLIT traces and metrics to Zerobus Ingest

info

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-apis access, and the Workspace access entitlement. The Collector requests all-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 needs USE CATALOG on the catalog, USE SCHEMA on the schema, and MODIFY and SELECT on each of the two tables. ALL PRIVILEGES isn'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 oauth2client extension 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.

SQL
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:

SQL
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:

Bash
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

DATABRICKS_CLIENT_ID

The Databricks service principal's client ID.

DATABRICKS_CLIENT_SECRET

The Databricks service principal's OAuth secret. The Collector reads it from the environment, so it stays out of the file.

DATABRICKS_WORKSPACE_URL

Your workspace URL, https://<workspace-url>. The token URL is this value with /oidc/v1/token added.

WORKSPACE_ID

Your workspace ID, <workspace-id>.

ZEROBUS_ENDPOINT

Your Zerobus Ingest endpoint host, without https:// or the port. The collector.yaml file in this step adds :443.

CATALOG and SCHEMA

The catalog and schema from Create the tables and grant access.

TABLE_PREFIX

The prefix from Create the tables and grant access.

Variable

Value

DATABRICKS_CLIENT_ID

The Databricks service principal's client ID.

DATABRICKS_CLIENT_SECRET

The Databricks service principal's OAuth secret. The Collector reads it from the environment, so it stays out of the file.

DATABRICKS_WORKSPACE_URL

Your workspace URL, https://<workspace-url>. The token URL is this value with /oidc/v1/token added.

WORKSPACE_ID

Your workspace ID, <workspace-id>.

ZEROBUS_ENDPOINT

Your Zerobus Ingest endpoint host, without https:// or the port. The collector.yaml file in this step adds :443.

CATALOG and SCHEMA

The catalog and schema from Create the tables and grant access.

TABLE_PREFIX

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:

YAML
# 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:

Bash
./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:

Bash
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:

Python
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_ENDPOINT and OTEL_EXPORTER_OTLP_METRICS_ENDPOINT take precedence over OTEL_EXPORTER_OTLP_ENDPOINT.
  • OTEL_TRACES_EXPORTER and OTEL_METRICS_EXPORTER choose the exporter for each signal. With a value of console or none, that signal doesn't go to the Collector.
  • OTEL_EXPORTER_OTLP_PROTOCOL=grpc switches 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:

Bash
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:

SQL
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 Failed to export logs batch code: 404, reason: Not Found

OpenLIT's events are on, so it exports logs, but this configuration has no logs pipeline.

Pass disable_events=True to openlit.init(), as in Install OpenLIT and point it at the Collector, or add a logs pipeline and table.

The application prints Transient error with connection refused, then Failed to export spans batch due to timeout, max retries or shutdown

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 otlp_endpoint is http://127.0.0.1:4318. Restart the Collector as soon as you can.

The Collector logs Partial success response with Span start_time_unix_nano is missing.

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 HTTP 400 with unmarshal: invalid TraceID length

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.

Symptom

Cause

Fix

The application prints Failed to export logs batch code: 404, reason: Not Found

OpenLIT's events are on, so it exports logs, but this configuration has no logs pipeline.

Pass disable_events=True to openlit.init(), as in Install OpenLIT and point it at the Collector, or add a logs pipeline and table.

The application prints Transient error with connection refused, then Failed to export spans batch due to timeout, max retries or shutdown

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 otlp_endpoint is http://127.0.0.1:4318. Restart the Collector as soon as you can.

The Collector logs Partial success response with Span start_time_unix_nano is missing.

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 HTTP 400 with unmarshal: invalid TraceID length

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​