Skip to main content

Overview

Telemetry providers export logs, distributed traces, and metrics to observability platforms. The gateway supports OpenTelemetry, Datadog, New Relic, Prometheus, and custom backends.

TelemetryProvider Interface

All telemetry providers must implement the TelemetryProvider abstract base class from src/secure_mcp_gateway/plugins/telemetry/base.py.

Required Methods

Optional Methods

Data Models

TelemetryResult

TelemetryLevel Enum

Example: Console Provider

Simple console logging provider from src/secure_mcp_gateway/plugins/telemetry/example_providers.py:20:

Example: Datadog Provider

From src/secure_mcp_gateway/plugins/telemetry/example_providers.py:86:

Example: Prometheus Provider

From src/secure_mcp_gateway/plugins/telemetry/example_providers.py:256:

Example: Custom Provider Template

From src/secure_mcp_gateway/plugins/telemetry/example_providers.py:334:

Configuration

Register your telemetry provider in the config file:

OpenTelemetry Configuration

The default provider is OpenTelemetry:

Using Telemetry in Your Code

Logging

Distributed Tracing

Metrics

Integration with OpenTelemetry Collector

The gateway exports telemetry to the OpenTelemetry Collector using OTLP:

Best Practices

Always use structured logging with context:
Set meaningful span attributes for distributed tracing:
Always handle initialization errors gracefully:
Implement proper shutdown for cleanup:

Testing Your Provider

Available Providers

Plugin Overview

Learn about the plugin system architecture

Observability

Set up full observability stack