Support Center Home


.NET Application Instrumentation

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

  1. (Recommended) Automatically instrument the application using a wizard in LogicMonitor. This option is the fastest way to get started, but gives you less control over how the trace data is emitted. When automatically instrumenting an application, you must download packages specific to the supported applications in use, configure an OTLP exporter, and run the instrumented .NET application. Operation names are automatically set. LogicMonitor provides a wizard for automatic instrumentation of .NET applications.
  2. Manually instrument the application. This is the only option for applications that use libraries and frameworks that are not supported by auto-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 manual and automatic instrumentation.

Requirements

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 Installing an OpenTelemetry Collector.

Automatically Instrumenting a .NET Application

  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 you are using applications that are not supported for the OpenTelemetry automatic instrumentation or if you want to customize how traces are generated by automatic instrumentation (For example, how operations are named).

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