OpenTelemetry Support
Using OpenTelemetry SDKs

OTel for .NET

8min

In this guide, we will walk you through the process of setting up and using OpenTelemetry in .NET. You will learn how to instrument a simple .Net. application to produce traces, metrics, and logs and export them to KloudMate.

Step 1: Prerequisites

Before diving into OpenTelemetry, be sure that you have the following installed:

Step 2: Example Application

If you already have a .NET application and don't need to create one from scratch, you can directly jump to the Instrumentation part of this guide.

For this tutorial, we will be using a basic Minimal API with ASP.NET Core application. However, OpenTelemetry .Net is compatible with other web frameworks as well. Feel free to adapt the instructions to your preferred framework.

Step 3: Installation

  1. Set up an environment in a new directory called dotnet-simple. Run the following command within this directory.
Text


2. Within the same directory, replace the content of Program.cswith the following code

Text


3. In the Properties subdirectory, replace the content of launchSettings.json with the following:

Text


4. Run the application using the following command then open http://localhost:8080/rolldice in your web browser:

Text


Step 4: Instrumentation

To install the instrumentation packages, we will use the  NuGet packages from OpenTelemetry. These packages will automatically generates telemetry data. 1. Add the packages

Text


2. In Program.cs, replace the following lines:

Text


With:

Text


Step 5: Run the Instrumented App

1. Run the instrumented application

Text


Note the output from the dotnet run.

2. From another terminal send a request using curl:

Text