Send data to Zerobus Ingest via the OpenTelemetry Collector
The token handling comes from the oauth2client extension in the OpenTelemetry Collector Contrib distribution. For the endpoints, the tables, the grants and the column reference, see Configure OpenTelemetry (OTLP) clients and the OpenTelemetry table reference.
Maintained by: the OpenTelemetry open-source project, in the open-telemetry/opentelemetry-collector-contrib repository.
Your application sends plain OTLP to a Collector on the same host. The Collector's oauth2client extension gets an OAuth token from a Databricks service principal, refreshes it before it expires, and forwards each signal to its own table in Zerobus Ingest. The application needs no token code, and you don't need to run a message bus between the application and the lakehouse.
Which path to use
Path | Use it when | Token handling |
|---|---|---|
Application exporter with a static token, see Quick start with static token | Runs under one hour | You generate the token. A static token expires after one hour. |
OpenTelemetry Collector with | A long-running service | The Collector gets the token at startup and refreshes it before it expires. |
When to use the Collector
- Your service runs for longer than one hour, so a static token would expire during the run.
- You want applications to send OTLP without credentials, and the Databricks service principal's secret to live in one place.
- You send traces, logs, and metrics, and want one configuration for all three.
How it works
The Collector has one OTLP receiver and three pipelines, one each for traces, logs, and metrics. Each pipeline exports through its own otlp exporter to its own table, and 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 extension refreshes the token before it expires, so exports continue after the first token's one-hour lifetime. Zerobus Ingest delivers each record at least one time when the client retries records that it hasn't received an acknowledgment for, so a retry can write a row more than one time.
The Collector holds accepted records in memory until it exports them, in the batch processor and in each exporter's sending queue. If the Collector stops before it exports them, those records are lost, and Zerobus Ingest's delivery guarantee doesn't cover records that haven't reached it.
Each exporter retries a failed batch for up to max_elapsed_time, which defaults to 300 seconds. If Zerobus Ingest stays unreachable longer, the Collector drops that batch. The OTLP exporter retries a ResourceExhausted response only when the server sends RetryInfo. Without it, the exporter drops the batch immediately, so raising max_elapsed_time doesn't help for those responses. A failed token request reaches the exporter as Unauthenticated, which the exporter doesn't retry, so that batch is also dropped immediately.
Each exporter's sending queue holds 1,000 requests by default (queue_size), and it rejects new data when full (block_on_overflow defaults to false), so a long outage can drop telemetry before the retry window ends. Persistent queues need a storage extension set in sending_queue.storage. This page's configuration sets neither sending_queue nor a storage extension.
Requirements
- A workspace in a region that supports Zerobus Ingest. See Availability.
- Target tables that meet the Zerobus Ingest table requirements. The three tables in Step 1 are managed Delta tables. For the endpoint and the workspace URL, see Zerobus Ingest.
- A Databricks service principal with an OAuth secret and the Workspace access entitlement. See Configure authentication. It needs
USE CATALOGon the catalog,USE SCHEMAon the schema, andMODIFYandSELECTon each of the three tables.ALL PRIVILEGESisn't enough. See Create a service principal and grant permissions. - Databricks Runtime 17.3 or above to create and query these tables. The table definitions in Step 1 turn on variant shredding, which needs 17.3. See Use variant shredding. Databricks Runtime 17.3 and above turns on shredding when it creates a table with
VARIANTcolumns, even without the shredding properties, so a table created there can only be read on 17.3 and above. - The OpenTelemetry Collector Contrib distribution. The
oauth2clientextension is in Contrib, not in the core distribution. - An application that exports OTLP over gRPC.
- Python 3 with
pipin the application's environment, for the Step 5 commands.
Step 1: Create the three tables and grant access
Replace <catalog>.<schema>.<prefix> with your catalog, schema, and table prefix, then run the three statements in Databricks SQL. They're the table definitions from the configure page.
Spans 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
);
Logs table:
CREATE TABLE <catalog>.<schema>.<prefix>_otel_logs (
record_id STRING,
time TIMESTAMP,
date DATE,
service_name STRING,
event_name STRING,
trace_id STRING,
span_id STRING,
time_unix_nano LONG,
observed_time_unix_nano LONG,
severity_number STRING,
severity_text STRING,
body VARIANT,
attributes VARIANT,
dropped_attributes_count INT,
flags INT,
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
>,
log_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
);
Metrics table:
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
);
Grant the Databricks service principal access. Replace <service-principal-uuid> with its application 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_logs TO `<service-principal-uuid>`;
GRANT MODIFY, SELECT ON TABLE <catalog>.<schema>.<prefix>_otel_metrics TO `<service-principal-uuid>`;
Step 2: 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 that the binary has the extension:
tar -xzf otelcol-contrib_<version>_linux_amd64.tar.gz
./otelcol-contrib --version
./otelcol-contrib components | grep oauth2client
Step 3: Create the Collector configuration
Set these variables in the shell where you start the Collector:
Variable | Value |
|---|---|
| The Databricks service principal's application ID ( |
| The Databricks service principal's OAuth secret |
| Your workspace URL without |
| Your workspace ID ( |
| Your Zerobus Ingest endpoint host, without |
| Your catalog, schema, and table prefix ( |
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 as collector.yaml. It follows the gRPC configuration on the configure page, with two changes. The configuration reads the endpoint, workspace URL, workspace ID, credentials, and table names from environment variables, so you set those values in the environment instead of editing the file. The receiver listens on 127.0.0.1 only. The HTTP/Protobuf version is on the configure page.
extensions:
oauth2client/spans:
client_id: ${env:DATABRICKS_CLIENT_ID}
client_secret: ${env:DATABRICKS_CLIENT_SECRET}
token_url: https://${env: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/logs:
client_id: ${env:DATABRICKS_CLIENT_ID}
client_secret: ${env:DATABRICKS_CLIENT_SECRET}
token_url: https://${env: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_logs"}]'
oauth2client/metrics:
client_id: ${env:DATABRICKS_CLIENT_ID}
client_secret: ${env:DATABRICKS_CLIENT_SECRET}
token_url: https://${env: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/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/logs:
endpoint: ${env:ZEROBUS_ENDPOINT}:443
auth:
authenticator: oauth2client/logs
headers:
x-databricks-zerobus-table-name: '${env:CATALOG}.${env:SCHEMA}.${env:TABLE_PREFIX}_otel_logs'
otlp/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
processors:
batch:
timeout: 5s # adjust as needed
send_batch_size: 10 # adjust as needed
service:
extensions: [oauth2client/spans, oauth2client/logs, oauth2client/metrics]
pipelines:
traces:
receivers: [otlp] # adjust as needed
processors: [batch]
exporters: [otlp/spans]
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlp/logs]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlp/metrics]
Step 4: Start the Collector
./otelcol-contrib --config collector.yaml
When the log shows Everything is ready. Begin running and processing data., the receiver accepts OTLP on 127.0.0.1:4317. The loopback address means only applications on the same host can send to the receiver. A receiver that other hosts must reach needs TLS and an authenticator on the otlp receiver, plus a network policy that limits access to port 4317. See the OpenTelemetry Collector configuration reference.
Step 5: Point your application at the Collector
For a Python application, install the OpenTelemetry distribution, the OTLP gRPC exporter, and the logging instrumentation. Then run the bootstrap command, which installs instrumentation libraries for the packages in the environment, such as the FastAPI and requests instrumentations. Run both commands in the application's environment, after its own dependencies are installed. Then run the application with the zero-code command:
pip install opentelemetry-distro opentelemetry-exporter-otlp-proto-grpc opentelemetry-instrumentation-logging
opentelemetry-bootstrap -a install
OTEL_SERVICE_NAME=<service-name> \
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317 \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
OTEL_TRACES_EXPORTER=otlp \
OTEL_METRICS_EXPORTER=otlp \
OTEL_LOGS_EXPORTER=otlp \
opentelemetry-instrument python <app>.py
Without opentelemetry-instrumentation-logging, the distribution exports traces and metrics but not records written with the standard logging module. pip install doesn't upgrade a package that's already installed, so in an environment that already has the logging package, run pip install -U opentelemetry-instrumentation-logging before you start the application. Other languages use their own OpenTelemetry SDK exporter with the same endpoint and protocol.
If the environment already sets OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, or a matching _PROTOCOL variable, unset it first. The signal-specific variables override the generic ones in the zero-code command.
Step 6: Query the tables
After you send traces, logs, and metrics, run the following queries. Each returns up to 10 rows, newest first.
- The spans query returns one row per span, with
service_nameset to the value ofOTEL_SERVICE_NAME. - The logs query returns one row per log record, with its severity and body.
- The metrics query returns one row per metric data point, with its name and metric type.
SELECT time, service_name, name, kind FROM <catalog>.<schema>.<prefix>_otel_spans ORDER BY time DESC LIMIT 10;
SELECT time, severity_text, to_json(body) AS body FROM <catalog>.<schema>.<prefix>_otel_logs ORDER BY time DESC LIMIT 10;
SELECT time, name, metric_type FROM <catalog>.<schema>.<prefix>_otel_metrics ORDER BY time DESC LIMIT 10;
Troubleshooting
Symptom | Cause | Fix |
|---|---|---|
The Collector logs | The example uses the | None. The configuration still runs. The warning names |
Application logs show | The Collector isn't running, or the application can't reach | Check that the Collector is running and that the receiver endpoint matches |
Rows sent while the Collector was down are missing, and rows sent after the restart land | The application's exports fail while the Collector is unreachable, and telemetry the application sends in that time can be lost. Records that the Collector accepted but hadn't exported are also lost if it stops. | Expect a gap for the time the Collector is down. Restart it as soon as you can. |
Python log records are missing |
| Install or upgrade the package as in Step 5. |
One data point is missing from a batch, and no error appears | A metric point with a timestamp of 0 doesn't land, while the other points in the same request do. The Collector doesn't log an error for it. | Check the timestamps at the source. |
Additional resources
- Configure OpenTelemetry (OTLP) clients: the endpoints, the headers, and the static-token quick start.
- OpenTelemetry table reference: the columns in each table.
- Example OpenTelemetry queries: more queries for spans, logs, and metrics.
- Zerobus Ingest errors: the error codes Zerobus Ingest returns.
- OpenTelemetry Collector configuration: the receivers, processors, exporters, and extensions this page uses.