Implementing Custom Telemetry Capture
Explore how to implement custom telemetry capture in a minimal .NET 7 API using OpenTelemetry SDK and Meter objects. Learn to create counters, monitor application metrics with dotnet-counters, and integrate telemetry for improved observability in microservices.
We'll cover the following...
We’ll create a simple example that will allow us to not only see how the OpenTelemetry SDK works but also how Meter objects can be used to house many different counters and data points:
Setting up the project
We create a new minimal API project in Visual Studio or with the
dotnetcommand line. Here’s the screenshot for the new minimal API project:
Here’s the screenshot for the dotnet command-line interface:
We have to be sure to uncheck the “Use controllers” checkbox to use minimal APIs if using the new project dialog from Visual Studio.
We add a NuGet reference to
System.Diagnostics.DiagnosticSourceandOpenTelemetry.Instrumentation.EventCount...