devops5 min read

Dual-exporting .NET metrics with OTLP and Prometheus

1 similar post
  • Prometheus
  • OpenTelemetry
  • dotnet-counters
  • Grafana

AI Summary

This article discusses how to de-risk observability migrations in .NET by dual-exporting metrics using both Prometheus and OpenTelemetry (OTLP) simultaneously. By adopting the native .NET Meter API alongside the OpenTelemetry SDK and Prometheus exporter NuGet packages, applications can expose an HTTP scrape endpoint for Prometheus while pushing metrics via OTLP. This incremental approach eliminates the need for a single cut-over event, uncouples code from vendor-specific Prometheus client libraries, and enables side-by-side comparison during migrations.

Key Takeaways

  • Use the native .NET Meter class, Counter, Gauge, and Histogram instruments instead of vendor-specific Prometheus client libraries.
  • Install the OpenTelemetry.Exporter.Prometheus.AspNetCore and OpenTelemetry.Exporter.OpenTelemetryProtocol packages to enable simultaneous export.
  • Expose the HTTP scrape endpoint via UseOpenTelemetryPrometheusScrapingEndpoint to let Prometheus collect metrics at regular intervals.

Why it matters

Migrating observability pipelines from legacy clients to OpenTelemetry often introduces high-risk cut-over events where production visibility can be lost. Dual-exporting allows teams to safely validate metrics in both systems simultaneously with minimal runtime overhead, ensuring continuous monitoring throughout the transition.

Conversation0

What would you add from your experience?

Checking your session…

Every good conversation starts with one perspective.