nat.plugins.ragaai.mixin.ragaai_catalyst_mixin#

Attributes#

Classes#

RAGATraceExporterOptWrite

Custom RAGATraceExporter that provides optional local file writing.

DynamicTraceExporterOptWrite

Custom DynamicTraceExporter that uses RAGATraceExporterOptWrite internally.

RagaAICatalystMixin

Mixin for RagaAI Catalyst exporters.

Module Contents#

logger#
class RAGATraceExporterOptWrite(*args, debug_mode: bool = False, **kwargs)#

Bases: ragaai_catalyst.tracers.exporters.ragaai_trace_exporter.RAGATraceExporter

Custom RAGATraceExporter that provides optional local file writing.

This subclass of RAGATraceExporter allows control over whether the rag_agent_traces.json file is written to the current directory.

Args:
debug_mode: When False (default), creates local rag_agent_traces.json file.

When True, skips local file creation for cleaner operation.

debug_mode = False#
prepare_trace(spans, trace_id)#
class DynamicTraceExporterOptWrite(
*args,
debug_mode: bool = False,
**kwargs,
)#

Bases: ragaai_catalyst.tracers.exporters.DynamicTraceExporter

Custom DynamicTraceExporter that uses RAGATraceExporterOptWrite internally.

This subclass of DynamicTraceExporter creates a RAGATraceExporterOptWrite instance instead of the default RAGATraceExporter, providing control over local file creation.

Args:
debug_mode: When False (default), creates local rag_agent_traces.json file.

When True, skips local file creation for cleaner operation.

_exporter#
class RagaAICatalystMixin(
*args,
base_url: str,
access_key: str,
secret_key: str,
project: str,
dataset: str,
tracer_type: str,
debug_mode: bool = False,
**kwargs,
)#

Mixin for RagaAI Catalyst exporters.

This mixin provides RagaAI Catalyst-specific functionality for OpenTelemetry span exporters. It handles RagaAI Catalyst project and dataset configuration and uses custom subclassed exporters to control local file creation behavior.

Key Features: - RagaAI Catalyst authentication with access key and secret key - Project and dataset scoping for trace organization - Integration with custom DynamicTraceExporter for telemetry transmission - Automatic initialization of RagaAI Catalyst client - Configurable local file creation via debug_mode parameter

This mixin uses subclassed exporters (RAGATraceExporterOptWrite and DynamicTraceExporterOptWrite) to provide clean control over whether the rag_agent_traces.json file is created locally.

This mixin is designed to be used with OtelSpanExporter as a base class:

Example:

class MyCatalystExporter(OtelSpanExporter, RagaAICatalystMixin):
    def __init__(self, base_url, access_key, secret_key, project, dataset, **kwargs):
        super().__init__(base_url=base_url, access_key=access_key,
                         secret_key=secret_key, project=project, dataset=dataset, **kwargs)

Initialize the RagaAI Catalyst exporter.

Args:

base_url: RagaAI Catalyst base URL. access_key: RagaAI Catalyst access key. secret_key: RagaAI Catalyst secret key. project: RagaAI Catalyst project name. dataset: RagaAI Catalyst dataset name. tracer_type: RagaAI Catalyst tracer type. debug_mode: When False (default), creates local rag_agent_traces.json file. When True, skips local file creation for cleaner operation. kwargs: Additional keyword arguments passed to parent classes.

_exporter#
async export_otel_spans(
spans: list[nat.plugins.opentelemetry.otel_span.OtelSpan],
) None#

Export a list of OtelSpans using the custom RagaAI Catalyst exporter.

This method uses the DynamicTraceExporterOptWrite instance to export spans, with local file creation controlled by the debug_mode setting.

Args:

spans (list[OtelSpan]): The list of spans to export.

Raises:

Exception: If there’s an error during span export (logged but not re-raised).