AgentOps (tracing)

AgentOps provides OpenTelemetry-backed decorators for tracing agent applications. Respan uses the spans AgentOps already creates, translates its native kinds and content into the Respan span contract, and exports them through the active Respan pipeline.

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-agentops agentops
2

Set your API key

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
3

Initialize and run

Initialize Respan before calling AgentOps-decorated code. You do not need to call agentops.init() or configure a second exporter.

Python
1from agentops import guardrail, task, tool, trace, workflow
2from respan import Respan
3from respan_instrumentation_agentops import AgentOpsInstrumentor
4
5respan = Respan(
6 instrumentations=[AgentOpsInstrumentor()],
7)
8
9
10@guardrail
11def validate_city(city: str) -> str:
12 if not city:
13 raise ValueError("city is required")
14 return city
15
16
17@tool
18def lookup_temperature(city: str) -> dict[str, object]:
19 return {"city": city, "temperature_c": 21}
20
21
22@task
23def format_forecast(payload: dict[str, object]) -> str:
24 return f"{payload['city']}: {payload['temperature_c']} C"
25
26
27@workflow
28def weather_workflow(city: str) -> str:
29 return format_forecast(lookup_temperature(validate_city(city)))
30
31
32@trace
33def run() -> str:
34 return weather_workflow("Paris")
35
36
37try:
38 print(run())
39finally:
40 respan.shutdown()
4

View your trace

Open the Traces page to inspect the decorator hierarchy, inputs and outputs, and failures.

What gets traced

The integration adapts the span kinds emitted by the installed AgentOps SDK.

AgentOps kindRespan spanCaptured details
session, workflowworkflowDecorator name, input, output, end state, tags
agentagentAgent name and AgentOps decorator content
task, operation, chain, httptaskOperation identity and decorator content
tooltoolTool name, input, output, and status
guardrailguardrailGuardrail name, input, output, and status
llmchatAgentOps GenAI messages, functions, model, and usage when emitted
texttextAgentOps text-generation attributes when emitted

The adapter promotes only attributes AgentOps actually emits. It does not synthesize model, token, tool-call, or response fields for decorator kinds that do not provide them.

Content controls

Content capture is enabled by default. Disable it when decorator arguments or results may contain sensitive data:

1from respan import Respan
2from respan_instrumentation_agentops import AgentOpsInstrumentor
3
4respan = Respan(
5 instrumentations=[AgentOpsInstrumentor(capture_content=False)]
6)

Operation names, kinds, tags, end state, and success/error status remain available.

Lifecycle

AgentOpsInstrumentor connects AgentOps’ tracing core to the active Respan tracer provider without starting AgentOps’ exporter or metrics pipeline. activate() and deactivate() are reference-counted across instrumentor instances, and Respan retains ownership of tracer-provider shutdown.

Initialize Respan before the first decorated call. Call respan.shutdown() during application shutdown to flush pending spans and restore the prior AgentOps tracing state.