Exporting opentelemetry to dynatrace in asp net core


ASP.NET is a popular programming used for web applications. It provides a powerful framework for dynamic and interactive . In this article, we will explore how to export OpenTelemetry data to Dynatrace in ASP.NET Core.

What is OpenTelemetry?

OpenTelemetry is an open-source observability framework that allows developers to collect, process, and export telemetry data from their applications. It provides a standardized way to instrument code and capture metrics, traces, and logs.

What is Dynatrace?

Dynatrace is an application performance monitoring (APM) tool that helps developers monitor and optimize the performance of their applications. It provides real-time insights into application behavior, identifies performance bottlenecks, and helps in troubleshooting issues.

Exporting OpenTelemetry to Dynatrace

To export OpenTelemetry data to Dynatrace in ASP.NET Core, we need to follow a few steps:

Step 1: Install the required packages

First, we need to install the necessary packages to enable OpenTelemetry and Dynatrace integration in our ASP.NET Core project. Open the Console and run the following command:

Install-Package OpenTelemetry.Exporter.Dynatrace

Step 2: Configure OpenTelemetry

Next, we need to configure OpenTelemetry to export data to Dynatrace. In the Startup.cs file of your ASP.NET Core project, add the following code:

services.AddOpenTelemetry(builder =>

This code configures OpenTelemetry to use the Dynatrace exporter and sets the service name to “MyAspNetCoreApp”. It also adds instrumentation for ASP.NET Core applications.

Step 3: Export OpenTelemetry data

Finally, we need to export the OpenTelemetry data to Dynatrace. In your ASP.NET Core controllers or middleware, you can use the OpenTelemetry API to capture metrics, traces, and logs. Here's an example:

using (var activity = ActivitySource.StartActivity("MyController.MyAction"))
    // Perform some 

    activity.SetTag("customTag", "customValue");

This code an activity with the name “MyController.MyAction” and sets a tag. The activity represents a unit of work or a span in the OpenTelemetry terminology. You can add additional tags, events, and attributes to capture more information.


In this article, we have seen how to export OpenTelemetry data to Dynatrace in ASP.NET Core. By integrating OpenTelemetry and Dynatrace, developers can gain valuable insights into the performance and behavior of their applications. This can help in identifying and resolving performance issues, improving user experience, and optimizing resource utilization.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents