redis_openai_agents.RedisTracingProcessor#
- class RedisTracingProcessor(redis_url='redis://localhost:6379', stream_name='agent_traces', buffer_size=100, trace_ttl=604800)[source]#
Stores OpenAI Agents SDK traces in Redis for observability.
This processor implements the TracingProcessor interface from the OpenAI Agents SDK to capture trace and span lifecycle events.
Traces are stored in: - Redis Streams for replay capability and time-series access - Redis Hashes for quick trace/span lookup by ID
- redis_url#
Redis connection URL.
- stream_name#
Name of the Redis Stream for storing events.
- buffer_size#
Number of events to buffer before flushing.
Initialize the tracing processor.
- Parameters:
redis_url (str) – Redis connection URL.
stream_name (str) – Name of the Redis Stream for events.
buffer_size (int) – Number of events to buffer before auto-flush.
trace_ttl (int) – TTL in seconds for trace data (default 7 days).
- __init__(redis_url='redis://localhost:6379', stream_name='agent_traces', buffer_size=100, trace_ttl=604800)[source]#
Initialize the tracing processor.
- Parameters:
redis_url (str) – Redis connection URL.
stream_name (str) – Name of the Redis Stream for events.
buffer_size (int) – Number of events to buffer before auto-flush.
trace_ttl (int) – TTL in seconds for trace data (default 7 days).
- Return type:
None
Methods
__init__([redis_url, stream_name, ...])Initialize the tracing processor.
aforce_flush()Async version of force_flush().
close()Close Redis connection.
force_flush()Force immediate flushing of buffered events.
get_spans(trace_id)Get all spans for a trace.
get_stream_length()Get the length of the trace stream.
get_trace(trace_id)Get trace data by ID.
initialize()Initialize Redis connection.
list_traces([limit, name_filter])List recent traces.
on_span_end(span)Called when a span completes.
on_span_start(span)Called when a span begins.
on_trace_end(trace)Called when a trace completes.
on_trace_start(trace)Called when a trace begins.
shutdown()Called on application shutdown.
trim_stream([max_length])Trim the trace stream to a maximum length.