Skip to content

metrics: optional OpenTelemetry export for agent and server - #10

Merged
martinhanzik merged 1 commit into
mainfrom
feat/otel-impl
Jun 5, 2026
Merged

metrics: optional OpenTelemetry export for agent and server#10
martinhanzik merged 1 commit into
mainfrom
feat/otel-impl

Conversation

@martinhanzik

Copy link
Copy Markdown
Contributor

Add opt-in OTLP metrics to both the agent and the server. Metrics are off by default: when disabled, init_metrics() returns None, the OpenTelemetry SDK is never imported, and every call-site helper is a no-op, so the base install stays lean and default behaviour is unchanged.

Each package gets a telemetry module that builds a MeterProvider with a delta-temporality OTLP exporter and a fresh service.instance.id per process, so several agents (or server instances sharing a port) on one host stay distinct. On the agent, host.name is a resource attribute, never a label.

Agent instruments: bytes read/sent, send round-trip latency, frame and connect outcomes, rotations, and observable gauges for files watched and a single aggregate shipping lag. Server instruments: connection accept and active counts, wire/written bytes, write and decompress latency, protocol errors, auth failures, and applied rename frames. Labels are bounded enums only; no metric is labelled by file path or client hostname.

Wire metrics via a metrics config block (honouring OTEL_SDK_DISABLED and OTEL_EXPORTER_OTLP_ENDPOINT), expose the SDK as an optional otel extra, and flush/shut the provider down on exit. Include a Grafana dashboard and focused tests for the enabled and disabled paths.

Add opt-in OTLP metrics to both the agent and the server. Metrics are off
by default: when disabled, init_metrics() returns None, the OpenTelemetry
SDK is never imported, and every call-site helper is a no-op, so the base
install stays lean and default behaviour is unchanged.

Each package gets a telemetry module that builds a MeterProvider with a
delta-temporality OTLP exporter and a fresh service.instance.id per process,
so several agents (or server instances sharing a port) on one host stay
distinct. On the agent, host.name is a resource attribute, never a label.

Agent instruments: bytes read/sent, send round-trip latency, frame and
connect outcomes, rotations, and observable gauges for files watched and a
single aggregate shipping lag. Server instruments: connection accept and
active counts, wire/written bytes, write and decompress latency, protocol
errors, auth failures, and applied rename frames. Labels are bounded enums
only; no metric is labelled by file path or client hostname.

Wire metrics via a `metrics` config block (honouring OTEL_SDK_DISABLED and
OTEL_EXPORTER_OTLP_ENDPOINT), expose the SDK as an optional `otel` extra,
and flush/shut the provider down on exit. Include a Grafana dashboard and
focused tests for the enabled and disabled paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@martinhanzik
martinhanzik merged commit 716f5ac into main Jun 5, 2026
21 checks passed
@martinhanzik
martinhanzik deleted the feat/otel-impl branch June 5, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant