OpenLIT (tracing)

OpenLIT is an open-source observability SDK for LLM applications. respan-instrumentation-openlit activates OpenLIT’s provider and framework instrumentation, normalizes its native OpenTelemetry spans to the Respan span contract, and exports them through the active Respan tracer provider.

The adapter does not wrap provider calls with a second Respan span. OpenLIT owns the library patches, while Respan owns normalization and export.

Create an account at platform.respan.ai and grab an API key.

Run npx @respan/cli setup to set up with your coding agent.

Setup

1

Install packages

$pip install respan-ai respan-instrumentation-openlit openai
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"

Set RESPAN_BASE_URL as well when exporting to a self-hosted or non-default Respan endpoint.

3

Initialize and call an instrumented library

1from openai import OpenAI
2from respan import Respan
3from respan_instrumentation_openlit import OpenLITInstrumentor
4
5respan = Respan(
6 app_name="openlit-support-agent",
7 instrumentations=[OpenLITInstrumentor()],
8)
9client = OpenAI()
10
11try:
12 response = client.chat.completions.create(
13 model="gpt-4o-mini",
14 messages=[
15 {"role": "user", "content": "Why is tracing useful?"},
16 ],
17 )
18 print(response.choices[0].message.content)
19finally:
20 respan.shutdown()

Creating Respan activates OpenLIT automatically. Do not call openlit.init() separately for the same process.

4

View your trace

Open the Traces page to inspect the normalized OpenLIT span, messages, model, usage, status, and nested application context.

What is traced

The adapter normalizes OpenLIT operation types into Respan’s canonical span types.

OpenLIT operationRespan log type
Chat model callchat
Text generation or completiontext
Embedding requestembedding
Tool or function executiontool
Agentagent
Workflowworkflow
Task or evaluation steptask
Guardrailguardrail

Model, provider, messages, tool definitions and calls, real provider token usage, standard HTTP and OpenAI attributes, and response status are retained when OpenLIT supplies them. OpenLIT-only cost, metric, framework, and legacy aliases are removed after canonical mapping. Provider failures keep their OpenTelemetry error status and include backend-visible status_code and error.message fields.

For OpenAI sync and async embedding calls, every returned vector element is stored in traceloop.entity.output; vectors are never dimension-truncated by the adapter. Setting capture_content=False omits both embedding inputs and vectors.

Configuration

ParameterTypeDefaultDescription
capture_contentboolTrueCapture prompts, completions, embedding inputs and vectors, tool definitions, and tool calls.
disabled_instrumentorslist[str] | NoneNoneOpenLIT instrumentor names to leave disabled.
pricing_jsonstr | NoneNoneCustom OpenLIT pricing data. The default packaged file is offline and contains no prices.
instrumentationslist[]Pass [OpenLITInstrumentor()] to Respan to activate the adapter.
api_keystr | NoneNoneFalls back to RESPAN_API_KEY.
base_urlstr | NoneNoneFalls back to RESPAN_BASE_URL.

Disable content capture

Disable content capture when prompts, responses, or tool arguments may contain sensitive data:

1from respan import Respan
2from respan_instrumentation_openlit import OpenLITInstrumentor
3
4respan = Respan(
5 instrumentations=[OpenLITInstrumentor(capture_content=False)],
6)

The adapter configures OpenLIT not to collect message content and also removes prompts, responses, embedding vectors, and other content fields from OpenLIT spans before export. Model, provider, usage, timing, and error fields remain available.

Limit OpenLIT instrumentation

Use OpenLIT’s disabled_instrumentors option when the process loads libraries that should not be patched:

1from respan import Respan
2from respan_instrumentation_openlit import OpenLITInstrumentor
3
4respan = Respan(
5 instrumentations=[
6 OpenLITInstrumentor(
7 disabled_instrumentors=["anthropic", "langchain"],
8 )
9 ],
10)

Add trace context

Use propagated attributes to group OpenLIT spans with the rest of an application workflow:

1from respan import Respan
2
3with Respan.propagate_attributes(
4 customer_identifier="user_123",
5 thread_identifier="conversation_abc",
6 trace_group_identifier="support_answer_workflow",
7 metadata={"plan": "pro"},
8):
9 response = client.chat.completions.create(
10 model="gpt-4o-mini",
11 messages=[{"role": "user", "content": "Summarize my ticket."}],
12 )

Avoid duplicate provider spans

Do not enable a provider-specific Respan instrumentor for the same client in the same process unless nested provider spans are intentional. For example, combining OpenLITInstrumentor() and a separate OpenAI instrumentor can produce two spans for one OpenAI request.

Activation is reference-counted. Shutdown removes only the OpenLIT hooks activated by this adapter and preserves instrumentation that was already active.