Skip to content
GitHubLog inStart free
cetra is not released yet. These docs describe the development version.

Databricks

Trace Databricks model calls with cetra through the OpenAI client.

Terminal window
pip install "cetra-sdk[openai]" openai
import os
import cetra
from openai import OpenAI
cetra.init(instrument=["openai"])
client = OpenAI(base_url="https://<WORKSPACE_HOST>/serving-endpoints", api_key=os.environ["DATABRICKS_TOKEN"])
response = client.chat.completions.create(
model="databricks-claude-sonnet-4-5",
messages=[{"role": "user", "content": "What is the capital of France?"}],
)
print(response.choices[0].message.content)
cetra.flush()
  • Each chat completion is an llm span with the provider databricks.
  • Input and output token counts come from the response.
  • Cost comes from the built-in prices for model names, not endpoint ids.
  • With cetra.init(instrument=["openai"]), the endpoint host is in server.address, and cetra names the provider from it.
  • Calling Databricks needs a workspace; this page is not tested against one.
  • The Databricks AI Gateway logs its traffic to a Unity Catalog trace table instead of exporting OTLP, so it is not a trace source for cetra; this page covers a workspace’s model endpoints through the OpenAI client.
  • No spans of Databricks are captured in the repository. cetra maps the hosts *.cloud.databricks.com, *.azuredatabricks.net, *.gcp.databricks.com to the provider databricks.
  • With plain OpenInference or the official OpenAI instrumentation in Python, the provider shows as openai: they do not record the endpoint. Use cetra.init(instrument=["openai"]) or OpenLLMetry.
  • If a field is missing, look at the span’s Attributes tab and compare it with Span attributes.