metrics: optional OpenTelemetry export for agent and server - #10
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
metricsconfig block (honouring OTEL_SDK_DISABLED and OTEL_EXPORTER_OTLP_ENDPOINT), expose the SDK as an optionalotelextra, and flush/shut the provider down on exit. Include a Grafana dashboard and focused tests for the enabled and disabled paths.