#574·watermill

metrics support opentelemetry

Author: ahkuiCreated May 26, 2025Updated Sep 17, 2026
Labelsenhancement

Motivation / Background

Currently, Watermill provides metrics support primarily through Prometheus (components/metrics). However, OpenTelemetry (OTel) has become the modern industry standard for observability.

Many developers are migrating their Go applications to use the OpenTelemetry SDK to collect and export metrics to various backends (via the OTel Collector) rather than binding directly to the Prometheus client. Adding native OpenTelemetry metrics support would allow users to seamlessly integrate Watermill into their existing OTel-instrumented applications and provide vendor-agnostic metrics out of the box.

Proposed Solution

Implement an OpenTelemetry metrics builder (similar in concept to the existing PrometheusMetricsBuilder) that utilizes the standard go.opentelemetry.io/otel/metric package.

This implementation should include:

  • Support for injecting an OpenTelemetry MeterProvider.
  • Instrumentation for standard Watermill components (Publishers, Subscribers, and Routers).
  • Tracking of key messaging metrics (e.g., publish/subscribe success/failure counts, handler execution times) using OTel instruments like Counters and Histograms.

Alternatives Considered

Relying on the existing Prometheus integration and using an adapter, or requiring users to write their own custom decorators. However, providing first-class, native OpenTelemetry support is much cleaner, more performant, and aligns perfectly with current cloud-native ecosystem trends.

(Note: I have already opened a PR to implement this feature here: #575)