Skip to main content
This guide walks through adding production-grade observability to your FrontMCP server — from zero-config tracing to connecting Coralogix, Datadog, or any OTLP-compatible backend.
Prerequisites: A working FrontMCP server with at least one tool. See Your First Tool if you need to get started.

What You’ll Get

  • Automatic spans for every tool call, resource read, auth flow, and HTTP request
  • Structured JSON logs with trace correlation (trace_id, span_id)
  • this.telemetry API for custom spans in your tools and plugins
  • Per-request log aggregation

Step 1: Install

This installs the observability package with @opentelemetry/api as the only hard dependency (~50KB). OTel SDK packages are optional peers — install only what you need.

Step 2: Enable Observability

Add the observability field to your @FrontMcp config:
That’s it. Every flow is now instrumented. Without a TracerProvider configured, all OTel calls are no-ops with zero overhead.
For fine-grained control, pass an object instead of true:

Step 3: Configure a Backend

The @FrontMcp({ ... }) snippets below show only the observability block for brevity. Your full config still needs info: { name, version } and the rest of your server fields.
See spans printed to your terminal — great for development:

Step 4: Use this.telemetry in Tools

Every execution context (tools, resources, prompts, agents) gets a this.telemetry API when observability is enabled. No imports, no context construction — it just works.
This produces:

Step 5: Structured Logging

When logging is enabled, every this.logger.info() call produces a structured JSON entry with automatic trace correlation:
Configure redaction for sensitive fields:

Step 6: Request Log Collection

Enable requestLogs to get a complete aggregated view of each request:

Step 7: Testing with Telemetry

Use the built-in testing utilities to verify your spans:

Span Hierarchy

Every request produces a span tree like this:

Attributes Reference

MCP Protocol Attributes (interoperable)

Standard OTel Attributes

FrontMCP Vendor Attributes


Best Practices

Don’t create spans with raw OTel API. Use this.telemetry.withSpan() or this.telemetry.startSpan() — they automatically inherit the trace context and add base attributes.
this.telemetry.addEvent('step-done') is cheaper than this.telemetry.startSpan('step'). Use events for milestones, spans for timed operations.
Always configure redactFields in production: ['password', 'token', 'secret', 'authorization', 'cookie'].
The otlp sink type works with all major platforms (Coralogix, Datadog, Logz.io, Grafana). Don’t build vendor-specific integrations.
The auto-instrumentation covers all SDK flows. Only add this.telemetry spans for your business logic operations (API calls, database queries, complex processing).

Next Steps

Telemetry API Reference

Full API docs for TelemetryAccessor, TelemetrySpan, and testing utilities

Rate Limiting

Add rate limiting alongside observability for production readiness