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.

1tracing:
2 enabled: true
3 adapters:
4 - name: FileSystem
5 filepath: "./logs/traces.jsonl"

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

OpenTelemetry Adapter

For production environments with observability platforms.

1tracing:
2 enabled: true
3 adapters:
4 - 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.

    1from nemoguardrails.tracing.adapters.base import InteractionLogAdapter
    2
    3class MyCustomAdapter(InteractionLogAdapter):
    4 name = "MyCustomAdapter"
    5
    6 def __init__(self, custom_option: str):
    7 self.custom_option = custom_option
    8
    9 def transform(self, interaction_log):
    10 # Transform logic for your backend
    11 pass
  2. Register the adapter in config.py.

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

    1tracing:
    2 enabled: true
    3 adapters:
    4 - name: MyCustomAdapter
    5 custom_option: "value"