Automatic OpenTelemetry data collection and resource detectors

Note

For .NET, Node.js, and Python applications:

For Java applications, use the Azure Monitor OpenTelemetry Distro.

This article explains automatic telemetry collection and resource detection in Application Insights. Use the Microsoft OpenTelemetry Distro for .NET, Node.js, and Python. Java continues to use the Azure Monitor OpenTelemetry Distro and its agent or native-image integrations. Select the tab for your language to review bundled instrumentation and resource metadata.

To learn more about OpenTelemetry concepts, see the OpenTelemetry overview.

Note

For Azure Function Apps, see Use OpenTelemetry with Azure Functions.

Included instrumentation libraries

The Microsoft OpenTelemetry Distro for .NET, Node.js, and Python and the Azure Monitor OpenTelemetry Distro for Java bundle instrumentation libraries to collect data automatically. First, enable OpenTelemetry and select Azure Monitor as the export destination. Don't initialize a second distro or a duplicate provider for the same signal.

Requests

Dependencies

Logging

  • ILogger

For more information about ILogger, see Logging in C# and .NET and code examples.

Footnotes

  • ¹: Supports automatic reporting of unhandled/uncaught exceptions
  • ²: Supports OpenTelemetry Metrics

Note

The Microsoft OpenTelemetry Distro versions' Azure Monitor integration and Azure Monitor OpenTelemetry for Java include mapping and logic to emit Application Insights standard metrics. For billing purposes, all OpenTelemetry metrics, whether automatically collected from instrumentation libraries or manually collected from custom coding, are currently considered Application Insights custom metrics. Learn more.

Tip

To reduce or increase the number of logs sent to Azure Monitor, configure logging to set the appropriate log level or apply filters. For example, you can choose to send only WARNING and ERROR logs to Azure Monitor.

Resource detectors

Resource detectors identify the service and host that produce telemetry. They read environment variables or host metadata and populate OpenTelemetry resource attributes such as service.name, service.instance.id, and cloud.resource_id.

What resource detectors power

Application Insights uses resource attributes to provide context for your telemetry:

  • Service and instance identification: Service attributes help set the Cloud Role Name and Cloud Role Instance shown in Application Map. Use a stable service name so instances of the same service aren't shown as separate components. For explicit configuration, see Set the Cloud Role Name and the Cloud Role Instance.
  • Compute linking: Attributes such as cloud.resource_id identify the Azure resource that hosts an application. Missing resource metadata can prevent Application Insights from linking application telemetry to its Azure compute resource.
  • Environment context: Host, operating-system, region, and service-version attributes describe where an application runs. The available attributes depend on the detector and hosting environment.

Resource attributes describe the service or process. Span attributes describe a single operation. Resource detection doesn't replace the trace-context propagation that connects requests and dependencies.

Supported environments

Detector availability and the attributes they collect vary by language, package version, and hosting integration. Use the registration code to see which detectors the distro enables, and the implementation to see which environment values they read. Select the repository tag that matches your installed package when checking a specific version.

Language or integration Detector registration and implementation
ASP.NET Core and .NET Microsoft OpenTelemetry detector registration and Azure detector implementations.
Node.js Microsoft OpenTelemetry resource configuration and Azure detector implementations.
Python Microsoft OpenTelemetry detector selection and Azure detector implementations.
Java agent Application Insights Java resource-provider configuration.
Java native Spring Boot integration and Quarkus Azure exporter. Detector configuration depends on the framework.

For Azure Functions, follow the Azure Functions OpenTelemetry guidance. For collector-based Kubernetes enrichment, see the Kubernetes attributes processor.

Resource metadata metric

The Azure Monitor exporters can send resource attributes in a special metric named _OTELRESOURCE_. The metric's properties carry the metadata; its numeric value isn't a measurement of application performance. This separate metadata record supplies resource context without adding every resource attribute to every telemetry item.

For the emitted name and properties, see the exporter implementations for .NET, Node.js, Python, and Java.

Note

Earlier Java agent releases used _APPRESOURCEPREVIEW_; version 3.5.3 removed that metric. The exporter implementations linked here use _OTELRESOURCE_. Check your exporter version before relying on a resource-metric name in a query or filter.

Turn off resource metadata export

Keep resource metadata export enabled unless you have a specific requirement to suppress it. Disabling it can remove compute-resource context used during troubleshooting. To control telemetry volume, use sampling or telemetry filters instead.

To stop exporting the resource metadata metric, set the applicable environment variable before the application starts, and then restart the application:

Language Environment variable Value
ASP.NET Core and .NET OTEL_DOTNET_AZURE_MONITOR_ENABLE_RESOURCE_METRICS false
Node.js APPLICATIONINSIGHTS_OPENTELEMETRY_RESOURCE_METRIC_DISABLED true
Python APPLICATIONINSIGHTS_OPENTELEMETRY_RESOURCE_METRIC_DISABLED true

These settings control resource-metric export, not detector execution or the collection of all application metrics. Resource attributes can still be used to populate cloud role fields on other telemetry. Remove the environment variable and restart the application to restore the default export behavior.

The settings in this table don't apply to Java. The linked Java exporter doesn't expose an equivalent metadata-only opt-out; don't disable all telemetry or remove service attributes to suppress this metric.

OTLP ingestion considerations

When you use native OTLP ingestion, preserve resource attributes on the OTLP resource. The Azure Monitor exporter settings in the preceding section don't control an OTLP exporter. Attributes such as service.name and cloud.resource_id still identify the service and its Azure host.

Troubleshooting, feedback, and support

Tip

The following sections are available across all OpenTelemetry Distro articles.

Troubleshooting

OpenTelemetry Feedback

To provide feedback:

Support

Select a tab for the language of your choice to discover support options.

Next steps