class OpenAIAgentsContextPropagationInterceptor(temporalio.client.Interceptor, temporalio.worker.Interceptor): (source)
Known subclasses: temporalio.contrib.openai_agents._otel_trace_interceptor.OTelOpenAIAgentsContextPropagationInterceptor
Constructor: OpenAIAgentsContextPropagationInterceptor(payload_converter, add_temporal_spans, start_traces)
Interceptor that propagates OpenAI agent tracing context through Temporal workflows and activities.
Warning
This API is experimental and may change in future versions. Use with caution in production environments.
This interceptor enables tracing of OpenAI agent operations across Temporal workflows and activities. It propagates trace context through workflow and activity boundaries, allowing for end-to-end tracing of agent operations.
The interceptor handles: 1. Propagating trace context from client to workflow 2. Propagating trace context from workflow to activities 3. Maintaining trace context across workflow and activity boundaries
- Example usage:
- interceptor = OpenAIAgentsTracingInterceptor() client = await Client.connect("localhost:7233", interceptors=[interceptor]) worker = Worker(client, task_queue="my-task-queue", interceptors=[interceptor])
| Method | __init__ |
Initialize the interceptor with a payload converter. |
| Method | context |
Extracts and initializes trace information the input header. |
| Method | get |
Extract trace context information from input headers. |
| Method | header |
Gets the OpenAI Agents trace/span data for the input header. |
| Method | intercept |
Intercepts activity calls to propagate trace context. |
| Method | intercept |
Intercepts client calls to propagate trace context. |
| Method | maybe |
Context manager that conditionally creates a span. |
| Method | set |
Inserts the OpenAI Agents trace/span data in the input header. |
| Method | span |
Initialize span context from header contents. |
| Method | trace |
Initialize trace context from header contents. |
| Method | workflow |
Returns the workflow interceptor class to propagate trace context. |
| Instance Variable | _add |
Undocumented |
| Instance Variable | _payload |
Undocumented |
| Instance Variable | _start |
Undocumented |
Inherited from Interceptor (via Interceptor):
| Method | intercept |
Method called for intercepting a Nexus operation. |
temporalio.converter.PayloadConverter = temporalio.converter.default().payload_converter, add_temporal_spans: bool = True, start_traces: bool = False):
(source)
¶
temporalio.contrib.openai_agents._otel_trace_interceptor.OTelOpenAIAgentsContextPropagationInterceptorInitialize the interceptor with a payload converter.
| Parameters | |
payloadtemporalio.converter.PayloadConverter | The payload converter to use for serializing/deserializing trace context. Defaults to the default Temporal payload converter. |
addbool | Whether to add temporal-specific spans to traces. |
startbool | Whether to start new traces if none exist. This will cause duplication if the underlying trace provider actually process start events. Primarily designed for use with Open Telemetry integration. |
temporalio.contrib.openai_agents._otel_trace_interceptor.OTelOpenAIAgentsContextPropagationInterceptorExtracts and initializes trace information the input header.
Extract trace context information from input headers.
| Parameters | |
input:_InputWithHeaders | Input with headers containing trace information. |
| Returns | |
dict[ | Dictionary containing trace context or None if no headers present. |
temporalio.contrib.openai_agents._otel_trace_interceptor.OTelOpenAIAgentsContextPropagationInterceptorGets the OpenAI Agents trace/span data for the input header.
temporalio.worker.ActivityInboundInterceptor) -> temporalio.worker.ActivityInboundInterceptor:
(source)
¶
Intercepts activity calls to propagate trace context.
| Parameters | |
next:temporalio.worker.ActivityInboundInterceptor | The next interceptor in the chain. |
| Returns | |
temporalio.worker.ActivityInboundInterceptor | An interceptor that propagates trace context for activity operations. |
temporalio.client.OutboundInterceptor) -> temporalio.client.OutboundInterceptor:
(source)
¶
Intercepts client calls to propagate trace context.
| Parameters | |
next:temporalio.client.OutboundInterceptor | The next interceptor in the chain. |
| Returns | |
temporalio.client.OutboundInterceptor | An interceptor that propagates trace context for client operations. |
temporalio.worker.WorkflowInterceptorClassInput) -> type[ _ContextPropagationWorkflowInboundInterceptor]:
(source)
¶
Returns the workflow interceptor class to propagate trace context.
| Parameters | |
input:temporalio.worker.WorkflowInterceptorClassInput | The input for creating the workflow interceptor. |
| Returns | |
type[ | The class of the workflow interceptor that propagates trace context. |