Implementing custom telemetry capture
We will 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:
- Create a new Minimal API project in Visual Studio or with the
dotnet
command line. Here is the screenshot for the new Minimal API project:
![Figure 13.1 – New project dialog in Visual Studio](https://static.packt-cdn.com/products/9781803232782/graphics/image/Figure_13.01_B17973.jpg)
Figure 13.1 – New project dialog in Visual Studio
Here is the screenshot for the dotnet
command-line interface:
![Figure 13.2 – Creating a Minimal API project from the dotnet CLI](https://static.packt-cdn.com/products/9781803232782/graphics/image/Figure_13.02_B17973.jpg)
Figure 13.2 – Creating a Minimal API project from the dotnet CLI
- Be sure to uncheck the Use controllers checkbox to use minimal APIs if using the new project dialog from Visual Studio:
![Figure 13.3 – Additional Information page in the New Project dialog](https://static.packt-cdn.com/products/9781803232782/graphics/image/Figure_13.03_B17973.jpg)
Figure 13.3 – Additional Information page in the New Project dialog
- Add a NuGet reference to
System.Diagnostics.DiagnosticSource
andOpenTelemetry.Instrumentation.EventCounters
:dotnet add package System...