DEV Community

Instana
Instana

Posted on • Originally published at instana.com on

Instana Introduces OpenTelemetry Exporter for .NET

What is OpenTelemetry?

OpenTelemetry is an open-source project hosted by the CNCF that provides APIs and SDKs for a variety of programming languages to instrument and collect observability data from applications. OpenTelemetry gives a framework for instrumenting, generating, collecting, and exporting telemetry data for analysis and understanding of software performance and behavior.

OpenTelemetry offers a vendor-neutral data format that can be integrated with any data processing backend. This is possible thanks to a concept called “exporters.” An exporter allows you to configure which backend(s) you want it sent to. The exporter decouples the instrumentation from the backend configuration. This makes it easy to switch backends without the pain of re-instrumenting your code.

OpenTelemetry and .NET

.NET is one of many languages supported by OpenTelemetry.

To instrument the .NET application, you have to add a corresponding NuGet package for the targeting runtime.

From there on, every collected trace will be exported by the .NET Instana exporter and directly sent to Instana’s backend.

The Span Exporter

Once the OpenTelemetry instrumentation package is added, it will trace appropriate library, generating spans for every time that an instrumented library is called.

But you have to tell the tracer what to do with these spans. That’s where the exporter comes in.

The exporter understands the vendor-neutral span format, converts it to a specific format, and sends this data to a backend to be processed and displayed later.

Example

Let’s say we have one simple ASP .NET Core application which uses MSSQL database as storage. The Application exposes two endpoints to interact with database. The first endpoint named /init is used for initialize database and insert one random integer value. Second endpoint /read is used to read previously generated and inserted random integer value.

If we want to instrument this application using OpenTelemetry we have to add appropriate OpenTelemetry instrumentation packages. For this ASP .Net Core app we have to add OpenTelemetry.Instrumentation.AspNetCore and because we are using MsSQL we have to add OpenTelemetry.Instrumentation.SqlClient packages to generate spans every time those two libraries are called.





At the end, we want to report it somewhere, so we need OTel exporter. In order to export traces from serverless environment to Instana backend we choose OpenTelemetry.Exporter.Instana.

The crucial thing, in OTel .Net world everything starts with TraceProviderso during initialization of this object we have to list all instrumentations and exporters. In our case that is SqlClientInstrumentation, AspNetCoreInstrumentation and because we want to report to Instana backend we have to add InstanaExporter.

Adding InstanaExporter

Also we have to provide two environment variables to the application before or during application starts. These variables are mandatory because exporter needs to know were to report generated spans:

ENV INSTANA_ENDPOINT_URL=endpoint_url

ENV INSTANA_AGENT_KEY=the_agent_key

Each HTTP call which results with database call will be captured in this case and immediately reported to Instana’s backend. Here we can see HTTP entry call /init with all following DB calls that are reported to Instana’s backend.

Instana injesting Open Telemetry Distrubuted Traces

Same for /read:

Instana and OpenTelemetry

We can see the converted and processed span data from OpenTelemetry in the Stan dashboard.

In conclusion, OpenTelemetry is rapidly gaining popularity in the observability world, especially with the flexibility to be exported, consumed and processed by a vendor specific backend.

Instana offers a convenient way to convert OpenTelemetry traces to the Instana platform for customers hosting the Instana Agent. But also for Node.js applications running in a serverless environment through the InstanaExporter.

Instana is wherever our customers are. By introducing an OpenTelemetry exporter for span data, we continue supporting use cases of our customers and continue with our integration of OpenTelemetry as a first class citizen into our observability platform.

Check our solution on OpenTelemetry Github repository

Let us know what you think! Check our OTel solution on OTel Github repository and leave us some feedback there or with support@instana.com.

Come back to see how we work with and support the OpenTelemetry project.

For more on Instana’s support of OpenTelemetry, here’s some additional reading material:

The post Instana Introduces OpenTelemetry Exporter for .NET appeared first on Instana.

Top comments (0)