OpenObserve Docs

Databricks → OpenObserve

Updated View MarkdownOpen in ChatGPTOpen in Claude

Automatically capture token usage, latency, and model metadata for every call to Databricks Model Serving endpoints. Databricks Model Serving exposes an OpenAI-compatible API, so instrumentation uses the standard OpenAI instrumentor pointed at your workspace serving endpoint.

Prerequisites

  • Python 3.9+
  • An OpenObserve account (cloud or self-hosted)
  • Your OpenObserve organisation ID and Base64-encoded auth token
  • A Databricks workspace with Model Serving enabled
  • A Databricks personal access token with model-serving permissions

Installation

pip install openobserve-python-sdk openinference-instrumentation-openai openai python-dotenv

Configuration

Create a .env file in your project root:

OPENOBSERVE_URL=https://api.openobserve.ai/
OPENOBSERVE_ORG=your_org_id
OPENOBSERVE_AUTH_TOKEN=Basic <your_base64_token>
DATABRICKS_HOST=https://adb-1234567890123456.7.azuredatabricks.net
DATABRICKS_TOKEN=dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXX
DATABRICKS_MODEL=databricks-llama-4-maverick

DATABRICKS_HOST is your workspace URL. DATABRICKS_MODEL is the serving endpoint name: either a Foundation Model API name (e.g. databricks-llama-4-maverick, databricks-claude-sonnet-4-6) or a custom endpoint name from your workspace.

Instrumentation

Call OpenAIInstrumentor().instrument() before creating the OpenAI client. Authenticate with your Databricks personal access token and point the client at the workspace serving endpoint.

from dotenv import load_dotenv
load_dotenv()

from openinference.instrumentation.openai import OpenAIInstrumentor
from openobserve import openobserve_init
from opentelemetry import trace

OpenAIInstrumentor().instrument()
openobserve_init()

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DATABRICKS_TOKEN"],
    base_url=f"{os.environ['DATABRICKS_HOST'].rstrip('/')}/serving-endpoints",
)

response = client.chat.completions.create(
    model=os.environ.get("DATABRICKS_MODEL", "databricks-llama-4-maverick"),
    messages=[{"role": "user", "content": "Explain distributed tracing in one sentence."}],
    max_tokens=100,
)
print(response.choices[0].message.content)
trace.get_tracer_provider().force_flush()

What Gets Captured

AttributeDescription
llm_systemopenai (OpenAI-compatible client)
llm_model_nameResolved model name returned by the API (e.g. meta-llama-4-maverick-040225)
gen_ai_request_max_tokensmax_tokens value from the request
gen_ai_response_modelSame as llm_model_name
gen_ai_operation_namechat
llm_token_count_promptPrompt tokens consumed
llm_token_count_completionCompletion tokens returned
llm_token_count_totalTotal tokens consumed
gen_ai_usage_input_tokensInput tokens (mirrors llm_token_count_prompt)
gen_ai_usage_output_tokensOutput tokens (mirrors llm_token_count_completion)
gen_ai_usage_total_tokensTotal tokens
openinference_span_kindLLM
operation_nameChatCompletion
input_mime_typeapplication/json
output_mime_typeapplication/json
durationEnd-to-end request latency
span_statusOK on success, ERROR on failure

Viewing Traces

  1. Log in to OpenObserve and navigate to Traces
  2. Spans appear with operation_name: ChatCompletion and llm_system: openai
  3. Note that the endpoint alias (e.g. databricks-llama-4-maverick) is kept in the request parameters (llm_invocation_parameters), while the resolved model version (e.g. meta-llama-4-maverick-040225) appears in llm_model_name
  4. Filter by llm_model_name to compare latency across different serving endpoints

Databricks trace in OpenObserve, Waterfall view with the ChatCompletion span attributes

Next Steps

With Databricks Model Serving instrumented, every inference call is recorded in OpenObserve. From here you can monitor latency per endpoint, track token usage across Foundation Model API endpoints, and set alerts on error spans.

Read More

Was this page helpful?

On this page