ObserveNow
...
Integrations
Applications

.NET / .NET Framework

Overview

This documentation will show you how to instrument your .NET applications to send OpenTelemetry traces to ObserveNow.

Setup

For apps running on .NET Auto Instrumentation

Install the following packages using dotnet add package command:

In the *.csproj file, the installed packages will look like:

C#


Configuration

Paste the below code snippet in the Program.cs file

C#


For apps running on .NET Framework 4.8.x Instrumentation - Manual

Install the following packages using dotnet add package command or NuGet package manager:

In the *.csproj file, the installed packages will look like:

C#


Configuration

Paste the below code snippet in the Program.cs file

C#


Every activity source which produce telemetry must be explicitly added to the tracer provider to start collecting traces from them. AddSource method on TracerProviderBuilder can be used to add a ActivitySource to the provider. The name of the ActivitySource (case-insensitive) must be the argument to this method.

Ensure that the OpsVerse Agent otel-collector is accessible from your .NET application environnment, either using an ingress or an IP

Adding Custom Span Attributes

Custom span attributes can be added at the service level or at (more granular) trace level. For service level span attributes, you can configure an environment variable OTEL_RESOURCE_ATTRIBUTES with key value pairs. For eg.

Shell


These will be picked up by the OpenTelemetry SDK and be brought into traces in your ObserveNow Instance.

For granular, trace level attributes, you can leverage ActivitySource to add custom span attributes. This is somewhat similar to the manual instrumentation steps above:

C#

Custom Span Attributes
Custom Span Attributes