Instrumentation

Overview

respan-tracing auto-instruments supported libraries to capture LLM calls, vector DB queries, and framework operations as spans — no code changes required. When a supported library is installed, its calls are automatically traced.

This page covers built-in auto-instrumentation via RespanTelemetry. For instrumentation plugins that work with the Respan entry point (e.g., OpenAI Agents, OpenAI SDK), see Instruments.

Configure

1from respan_tracing import RespanTelemetry, Instruments

Enable all (default)

1telemetry = RespanTelemetry(api_key="your-api-key")
2# All installed libraries are auto-instrumented

Enable specific instruments only

1telemetry = RespanTelemetry(
2 api_key="your-api-key",
3 instruments={Instruments.OPENAI, Instruments.ANTHROPIC},
4)

Block specific instruments

1telemetry = RespanTelemetry(
2 api_key="your-api-key",
3 block_instruments={Instruments.REQUESTS, Instruments.URLLIB3},
4)

Disable all auto-instrumentation

1telemetry = RespanTelemetry(
2 api_key="your-api-key",
3 instruments=set(),
4)

Disable auto-instrumentation (when using plugins)

When using instrumentation plugins with the Respan entry point, set auto_instrument=False on RespanTelemetry to avoid duplicate spans:

1from respan import Respan, propagate_attributes
2from respan_instrumentation_openai_agents import OpenAIAgentsInstrumentor
3
4respan = Respan(
5 api_key="your-api-key",
6 auto_instrument=False,
7 instrumentations=[OpenAIAgentsInstrumentor()],
8)

Available instruments

AI/ML providers

InstrumentLibrary
Instruments.OPENAIopenai
Instruments.ANTHROPICanthropic
Instruments.COHEREcohere
Instruments.MISTRALmistralai
Instruments.OLLAMAollama
Instruments.GROQgroq
Instruments.TOGETHERtogether
Instruments.REPLICATEreplicate
Instruments.TRANSFORMERStransformers

Cloud AI services

InstrumentLibrary
Instruments.BEDROCKboto3 (Bedrock)
Instruments.SAGEMAKERboto3 (SageMaker)
Instruments.VERTEXAIgoogle-cloud-aiplatform
Instruments.GOOGLE_GENERATIVEAIgoogle-generativeai
Instruments.WATSONXibm-watsonx-ai
Instruments.ALEPHALPHAaleph-alpha-client

Vector databases

InstrumentLibrary
Instruments.PINECONEpinecone
Instruments.QDRANTqdrant-client
Instruments.CHROMAchromadb
Instruments.MILVUSpymilvus
Instruments.WEAVIATEweaviate-client
Instruments.LANCEDBlancedb
Instruments.MARQOmarqo

Frameworks

InstrumentLibrary
Instruments.LANGCHAINlangchain
Instruments.LLAMA_INDEXllama-index
Instruments.HAYSTACKhaystack
Instruments.CREWcrewai
Instruments.MCPmcp

Infrastructure

InstrumentLibrary
Instruments.REDISredis
Instruments.REQUESTSrequests
Instruments.URLLIB3urllib3
Instruments.PYMYSQLpymysql
Instruments.THREADINGthreading (stdlib)

THREADING is always enabled by default for proper context propagation across threads. It can be explicitly blocked with block_instruments.

Environment variables

VariableDescriptionDefault
RESPAN_API_KEYRespan API key
RESPAN_BASE_URLAPI base URLhttps://api.respan.ai/api
RESPAN_LOG_LEVELSDK log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)INFO
RESPAN_BATCHING_ENABLEDEnable batch span processing (true / false)true

Troubleshooting

If you see warnings like Failed to initialize Requests instrumentation, install the optional OpenTelemetry instrumentations:

$pip install opentelemetry-instrumentation-requests opentelemetry-instrumentation-urllib3

This is optional — tracing works without them. Only needed if your app uses requests or urllib3 and you want those calls traced.