Adapter Configurations

View as Markdown

You can set up the following adapters for tracing.

The following table summarizes the list of adapters supported by the NeMo Guardrails library and their use cases.

Adapter TypeUse CaseConfiguration
FileSystemDevelopment, debugging, local loggingfilepath: "./logs/traces.jsonl"
OpenTelemetryProduction, monitoring platforms, distributed systemsRequires SDK configuration
CustomSpecialized backends or formatsImplement InteractionLogAdapter

The following sections explain how to configure each adapter in config.yml.

FileSystem Adapter

For development and debugging, use the FileSystem adapter to log traces locally.

tracing:
enabled: true
adapters:
- name: FileSystem
filepath: "./logs/traces.jsonl"

For working examples, refer to the Tracing Guardrails Quickstart notebook.

OpenTelemetry Adapter

For production environments with observability platforms.

tracing:
enabled: true
adapters:
- name: OpenTelemetry

For working examples, refer to the Tracing Guardrails with Jaeger notebook.

Custom Adapter

You can create custom adapters and use them in your application code.

  1. Create custom adapters for specialized backends or formats for your use case.

    from nemoguardrails.tracing.adapters.base import InteractionLogAdapter
    class MyCustomAdapter(InteractionLogAdapter):
    name = "MyCustomAdapter"
    def __init__(self, custom_option: str):
    self.custom_option = custom_option
    def transform(self, interaction_log):
    # Transform logic for your backend
    pass
  2. Register the adapter in config.py.

    from nemoguardrails.tracing.adapters.registry import register_log_adapter
    register_log_adapter(MyCustomAdapter, "MyCustomAdapter")
  3. Use the adapter in config.yml.

    tracing:
    enabled: true
    adapters:
    - name: MyCustomAdapter
    custom_option: "value"