...

/

Implementing Custom Telemetry Capture

Implementing Custom Telemetry Capture

Learn how to implement custom telemetry capture in a minimal API project using System.Diagnostics.DiagnosticSource and OpenTelemetry.

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

  1. We create a new minimal API project in Visual Studio or with the dotnet command line. Here’s the screenshot for the new minimal API project:

Press + to interact
New project dialog in Visual Studio
New project dialog in Visual Studio

  Here’s the screenshot for the dotnet command-line interface:

Press + to interact
Creating a minimal API project from the dotnet CLI
Creating a minimal API project from the dotnet CLI
  1. We have to be sure to uncheck the “Use controllers” checkbox to use minimal APIs if using the new project dialog from Visual Studio.

Press + to interact
Additional Information page in the New Project dialog
Additional Information page in the New Project dialog
  1. We add a NuGet reference to System.Diagnostics.DiagnosticSource and OpenTelemetry.Instrumentation.EventCount ...