Overview
All Respan instrumentation plugins implement a simple protocol withname, activate(), and deactivate(). This lets you build plugins for any vendor SDK and have them work with Respan().
Protocol
| Attribute/Method | Description |
|---|---|
name | Unique identifier for the plugin (e.g. "openai-agents", "openai"). |
activate() | Called by Respan.__init__(). Registers hooks/processors with the vendor SDK. |
deactivate() | Called by Respan.shutdown(). Cleans up hooks/processors. |
Building a custom plugin
A plugin typically:- Registers a hook or processor with the vendor SDK in
activate(). - On each SDK event, converts it to a
ReadableSpanusingbuild_readable_span(). - Injects the span into the OTEL pipeline using
inject_span().
Minimal example
Key functions
| Function | Module | Description |
|---|---|---|
build_readable_span() | respan_tracing.utils.span_factory | Creates a ReadableSpan with proper trace/span IDs, timestamps, and attributes. Automatically reads propagated attributes from the current context. |
inject_span() | respan_tracing.utils.span_factory | Injects a ReadableSpan into the global OTEL processor chain for export. |
read_propagated_attributes() | respan_tracing.utils.span_factory | Reads the current propagate_attributes() context. Useful if you need to inspect attributes before building the span. |
Required attributes
For spans to be processed and displayed correctly by the Respan backend:| Attribute | Required | Description |
|---|---|---|
traceloop.span.kind | Yes | One of "workflow", "agent", "task", "tool". |
traceloop.entity.name | Yes | Human-readable span name. |
llm.request.type | For LLM spans | Set to "chat" to trigger prompt/completion parsing. |
gen_ai.request.model | For LLM spans | Model name. |
Existing plugins
| Plugin | Package | SDK |
|---|---|---|
| OpenAI Agents SDK | respan-instrumentation-openai-agents | openai-agents |
| OpenAI | respan-instrumentation-openai | openai |