After enabling Aspire for your application, you get OpenTelemetry integration for free thanks to the included ServiceDefaults code. This will setup OpenTelemetry using a set of defaults: Unfortunately this default configuration didn’t pick up any of the custom metrics I added. I first thought that this meant that I couldn’t use the service defaults anymore and configure the OpenTelemetry integration manually. But then I discovered that you can change/extend the default configuration in a specific project by using the ConfigureOpenTelemetryTracerProvider and/or ConfigureOpenTelemetryMeterProvider methods. Add your custom OpenTelemetry configuration after calling the Aspire builder.AddServiceDefaults() : Now our custom metrics appear nicely in the Aspire dashboard: More information Welcome to Aspire | Aspire Enabling .NET Aspire for an existing solution Replacing EventCounters with the new Metrics API
If you've been using EventCounters for instrumenting your .NET applications, it's time to consider migrating to the newer System.Diagnostics.Metrics API. Based on the OpenTelemetry specification, the Metrics API offers a more modern, flexible, and standardized approach to application instrumentation. Why migrate? The Metrics API provides several advantages over EventCounters: Industry Standard : Built on OpenTelemetry, ensuring compatibility with a wide ecosystem of monitoring tools Better Performance : More efficient with lower overhead Richer Functionality : Support for histograms, exemplars, and more sophisticated metric types Improved API Design : Cleaner, more intuitive interface for defining and recording metrics Better Tooling Support : Growing ecosystem support from APM vendors and monitoring solutions Microsoft has indicated that EventCounters are in maintenance mode, with new development focused on the Metrics API. So reasons enough to m...