.NET / .NET Framework
This documentation will show you how to instrument your .NET applications to send OpenTelemetry traces to ObserveNow.
Install the following packages using dotnet add package command:
- OpenTelemetry.Exporter.Console: (Optional: For traces to be displayed on Console during development)
In the *.csproj file, the installed packages will look like:
Paste the below code snippet in the Program.cs file
Install the following packages using dotnet add package command or NuGet package manager:
- OpenTelemetry.Exporter.Console (Optional: For traces to be displayed on Console during development)
In the *.csproj file, the installed packages will look like:
Paste the below code snippet in the Program.cs file
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
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.
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: