.NET Application Instrumentation

Last Updated: 11 July, 2022

You can use the following methods for OpenTelemetry-facilitated instrumentation of a .NET application:

  • (Recommended) Automatic instrumentation—This option is the fastest way to get started, but gives you less control over how the trace data is emitted. LogicMonitor provides a wizard for automatic instrumentation of .NET applications.
    Alternatively, you can automatically instrument a .NET application outside your LogicMonitor portal. This requires you to download packages specific to the supported applications in use, configure an OTLP exporter, and run the instrumented .NET application. Operation names are automatically set. For more information, see the supported applications from OpenTelemetry.
  • Manual instrumentation—This is the only option for applications that use libraries and frameworks that are not supported by automatic instrumentation. With manual instrumentation, you write code in your application that uses the OpenTelemetry SDK to capture and emit the trace data.

Depending on your environment, you may need a combination of both automatic and manual instrumentation.

Requirements for Instrumenting a .NET Application with LogicMonitor

To instrument a .NET application, you must install and configure an OpenTelemetry Collector to forward trace data to your LogicMonitor portal. For more information, see OpenTelemetry Collector Installation.

Automatically Instrumenting a .NET Application using the Instrumentation Wizard in LogicMonitor

Note: To automatically instrument a Java application outside your LogicMonitor portal, see OpenTelemetry’s Automatic Instrumentation documentation.

  1. Navigate to Traces > Onboarding and select Instrument Your Application.
  2. Click Select for .NET, and then select Automatic (Recommended).
  3. Download the .NET SDK and inject it into your application. This SDK is a LogicMonitor-wrapped version of the .NET SDK provided by OpenTelemetry.
  4. When prompted, enter the following information:
    • (Required) The name of the service you are instrumenting
      This is also used as the display name for the service in your LogicMonitor portal. Special characters, including spaces, are not allowed.
    • (Recommended) The service namespace
      This is used to represent a grouping of services. If specified, it is added as a property to each auto-created service and a parent service is created to represent the namespace. You may find this useful for organizing applications with multiple underlying services.
    • (Recommended) Custom tags
      These are associated with all the operations for this service. For example, you can add tags that represent the business or technical priority of the service.

Note: LogicMonitor requires the following custom tags to map traces to existing monitored resources: ip, resource.type (which should be set to kubernetes-pod, cloud, or host), and host.name (which should be the pod name for Kubernetes). Use these custom tags when possible to ensure that traces are shown in the context of logs, metrics, and alerts.

  1. Copy the environment variables that are generated based on the information you provided and add them to your application before starting it. 

Note: If your OpenTelemetry Collector was installed on a different server, you may need to update the value of Dotel.export.otlp.endpoint from localhost to the IP of the server where the OpenTelemetry Collector is running.

Manually Instrumenting a .NET Application

You can manually instrument your .NET applications if your application is not supported for OpenTelemetry automatic instrumentation, or if you want to customize how traces are generated by automatic instrumentation. For example, you may want to customize how operations are named. For more information about the applications that are not supported by automatic instrumentation, see OpenTelemetry .NET from OpenTelemetry.

For more information about manually instrumenting your .NET application, the OpenTelemetry SDK, creating and enriching traces, see OpenTelemetry’s Manual Instrumentation documentation.

In This Article