Skip to content

feat: add sending of metrics directly to otel collector via prom-client bridge - #1714

Draft
mutambaraf wants to merge 2 commits into
developfrom
150-send-otel-metrics-data-directly-to-alloy
Draft

feat: add sending of metrics directly to otel collector via prom-client bridge#1714
mutambaraf wants to merge 2 commits into
developfrom
150-send-otel-metrics-data-directly-to-alloy

Conversation

@mutambaraf

@mutambaraf mutambaraf commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces the functionality to send metrics directly to otel collector via a prom-client bridge. By introducing PromClientMetricProducer, a custom OpenTelemetry MetricProducer that bridges metrics already collected via prom-client (HTTP request counts/durations, GraphQL request/error/response-size stats, Node.js default process metrics) into the OpenTelemetry SDK's export pipeline. At each collection cycle it reads prom-client's global registry (register.getMetricsAsJSON()) and converts each metric, counters, gauges, histograms, and summaries into OTel's MetricData shape.tracing.ts now registers a PeriodicExportingMetricReader with this producer and an OTLPMetricExporter, gated behind OTEL_EXPORTER_OTLP_METRICS_ENDPOINT (mirroring how traces/logs are already conditionally enabled). The new @opentelemetry/exporter-metrics-otlp-http dependency provides that exporter and exports on 60s interval.

Motivation and Context

This change is required to improve the efficiency of sending metrics directly to otel collector. Metrics currently only reach observability tooling via a pull-based /metrics endpoint for direct Prometheus scraping, separate from traces and logs, which already export through OTel/OTLP to Alloy. .

Changes

  1. Added "@opentelemetry/exporter-metrics-otlp-http" to both package.json and package-lock.json. This package helps in exporting metrics to otel collector.
  2. Created a new file "PromClientMetricProducer.ts" which includes the implementation of the prom-client bridge. This bridge collects metrics from the prom-client and sends them to the otel collector directly.
  3. The bridge uses the MetricProducer interface from '@opentelemetry/sdk-metrics' to implement the 'collect' method. This method is called to collect the metrics from the prom-client.

How Has This Been Tested?

Fixes Jira Issue

Part of: https://github.com/isisbusapps/observability/issues/150

Tests included/Docs Updated?

Manual testing

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@mutambaraf mutambaraf changed the title feat: add sending of metrics directly to otel collector via prom-client bridge feat : add sending of metrics directly to otel collector via prom-client bridge Aug 6, 2026
@mutambaraf mutambaraf changed the title feat : add sending of metrics directly to otel collector via prom-client bridge feat: add sending of metrics directly to otel collector via prom-client bridge Aug 6, 2026
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