OpenTelemetry 1.13.1

OpenTelemetry .NET SDK

NuGet NuGet

Table of Contents

Installation

dotnet add package OpenTelemetry

Introduction

OpenTelemetry SDK is a reference implementation of the OpenTelemetry API. It implements the Logging API, Metrics API, Tracing API, Resource API, and the Context API. Once a valid SDK is installed and configured all the OpenTelemetry API methods, which were no-ops without an SDK, will start emitting telemetry. This SDK also ships with ILogger integration to automatically capture and enrich logs emitted using Microsoft.Extensions.Logging.

The SDK deals with concerns such as sampling, processing pipelines (exporting telemetry to a particular backend, etc.), metrics aggregation, and other concerns outlined in the OpenTelemetry Specification. In most cases, users indirectly install and enable the SDK when they install an exporter.

To learn how to set up and configure the OpenTelemetry SDK see: Getting started. For additional details about initialization patterns see: Initialize the SDK.

Troubleshooting

All the components shipped from this repo uses EventSource for its internal logging. The name of the EventSource used by OpenTelemetry SDK is "OpenTelemetry-Sdk". To know the EventSource names used by other components, refer to the individual readme files.

While it is possible to view these logs using tools such as PerfView, dotnet-trace etc., this SDK also ships a self-diagnostics feature, which helps with troubleshooting.

Self-diagnostics

OpenTelemetry SDK ships with built-in self-diagnostics feature. This feature, when enabled, will listen to internal logs generated by all OpenTelemetry components (i.e EventSources whose name starts with "OpenTelemetry-") and writes them to a log file.

The self-diagnostics feature can be enabled/changed/disabled while the process is running (without restarting the process). The SDK will attempt to read the configuration file every 10 seconds in non-exclusive read-only mode. The SDK will create or overwrite a file with new logs according to the configuration. This file will not exceed the configured max size and will be overwritten in a circular way.

To enable self-diagnostics, go to the current working directory of your process and create a configuration file named OTEL_DIAGNOSTICS.json with the following content:

{
    "LogDirectory": ".",
    "FileSize": 32768,
    "LogLevel": "Warning",
    "FormatMessage": "true"
}

To disable self-diagnostics, delete the above file.

Tip: In most cases, you could just drop the file along your application. On Windows, you can use Process Explorer, double click on the process to pop up Properties dialog and find "Current directory" in "Image" tab. Internally, it looks for the configuration file located in GetCurrentDirectory, and then AppContext.BaseDirectory. You can also find the exact directory by calling these methods from your code.

Configuration Parameters

  1. LogDirectory is the directory where the output log file will be stored. It can be an absolute path or a relative path to the current directory.

  2. FileSize is a positive integer, which specifies the log file size in KiB. This value must be within range [1024, 131072] (1 MiB /<= size /<= 128 MiB), or it will be rounded to the closest upper or lower limit. The log file will never exceed this configured size, and will be overwritten in a circular way.

  3. LogLevel is the lowest level of the events to be captured. It has to be one of the values of the EventLevel enum. The level signifies the severity of an event. Lower severity levels encompass higher severity levels. For example, Warning includes the Error and Critical levels.

  4. FormatMessage is a boolean value that controls whether log messages should be formatted by replacing placeholders ({0}, {1}, etc.) with their actual parameter values. When set to false (default), messages are logged with unformatted placeholders followed by raw parameter values. When set to true, placeholders are replaced with formatted parameter values for improved readability.

    Example with FormatMessage: false (default):

    2025-07-24T01:45:04.1020880Z:Measurements from Instrument '{0}', Meter '{1}' will be ignored. Reason: '{2}'. Suggested action: '{3}'{dotnet.gc.collections}{System.Runtime}{Instrument belongs to a Meter not subscribed by the provider.}{Use AddMeter to add the Meter to the provider.}
    

    Example with FormatMessage: true:

    2025-07-24T01:44:44.7059260Z:Measurements from Instrument 'dotnet.gc.collections', Meter 'System.Runtime' will be ignored. Reason: 'Instrument belongs to a Meter not subscribed by the provider.'. Suggested action: 'Use AddMeter to add the Meter to the provider.'
    

Remarks

A FileSize-KiB log file named as ExecutableName.ProcessId.log (e.g. foobar.exe.12345.log) will be generated at the specified directory LogDirectory, into which logs are written to.

If the SDK fails to parse the LogDirectory, FileSize or LogLevel fields as the specified format, the configuration file will be treated as invalid and no log file would be generated.

When the LogDirectory or FileSize is found to be changed, the SDK will create or overwrite a file with new logs according to the new configuration. The configuration file has to be no more than 4 KiB. In case the file is larger than 4 KiB, only the first 4 KiB of content will be read.

The log file might not be a proper text file format to achieve the goal of having minimal overhead and bounded resource usage: it may have trailing NULs if log text is less than configured size; once write operation reaches the end, it will start from beginning and overwrite existing text.

References

Showing the top 20 packages that depend on OpenTelemetry.

Packages Downloads
OpenTelemetry.Exporter.Jaeger
Jaeger exporter for OpenTelemetry .NET
5,661
OpenTelemetry.Extensions.Hosting
Contains extensions to start OpenTelemetry in applications using Microsoft.Extensions.Hosting
4,927
OpenTelemetry.Instrumentation.Http
Http instrumentation for OpenTelemetry .NET
524
OpenTelemetry.Extensions.Hosting
Contains extensions to start OpenTelemetry in applications using Microsoft.Extensions.Hosting
517
OpenTelemetry.Instrumentation.AspNetCore
ASP.NET Core instrumentation for OpenTelemetry .NET
511
OpenTelemetry.Extensions.Hosting
Contains extensions to start OpenTelemetry in applications using Microsoft.Extensions.Hosting
327
OpenTelemetry.Instrumentation.Http
Http instrumentation for OpenTelemetry .NET
66
OpenTelemetry.Extensions.Hosting
Contains extensions to start OpenTelemetry in applications using Microsoft.Extensions.Hosting
62
OpenTelemetry.Instrumentation.SqlClient
SqlClient instrumentation for OpenTelemetry .NET
62
OpenTelemetry.Extensions.Hosting
Startup extensions to register OpenTelemetry into the applications using Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.Hosting
61
OpenTelemetry.Instrumentation.AspNetCore
ASP.NET Core instrumentation for OpenTelemetry .NET
61
OpenTelemetry.Instrumentation.Http
Http instrumentation for OpenTelemetry .NET
61
OpenTelemetry.Instrumentation.SqlClient
SqlClient instrumentation for OpenTelemetry .NET
60
OpenTelemetry.Exporter.Console
Console exporter for OpenTelemetry .NET
59
OpenTelemetry.Instrumentation.SqlClient
SqlClient instrumentation for OpenTelemetry .NET
59
OpenTelemetry.Exporter.Jaeger
Package Description
59
OpenTelemetry.Instrumentation.AspNetCore
ASP.NET Core instrumentation for OpenTelemetry .NET
59
OpenTelemetry.Exporter.Console
Console exporter for OpenTelemetry .NET
58
OpenTelemetry.Instrumentation.AspNetCore
ASP.NET Core instrumentation for OpenTelemetry .NET
58
OpenTelemetry.Extensions.Hosting
OpenTelemetry hosting integration
58

For highlights and announcements see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.13.1/RELEASENOTES.md. For detailed changes see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.13.1/src/OpenTelemetry/CHANGELOG.md.

Version Downloads Last updated
1.13.1 5 10/10/2025
1.13.0 3 10/01/2025
1.12.0 336 05/01/2025
1.11.2 27 03/07/2025
1.11.1 30 01/25/2025
1.11.0 31 01/17/2025
1.11.0-rc.1 32 12/14/2024
1.10.0 36 11/15/2024
1.10.0-rc.1 34 11/05/2024
1.10.0-beta.1 32 10/01/2024
1.9.0 46 06/15/2024
1.9.0-rc.1 45 06/08/2024
1.9.0-alpha.1 39 05/28/2024
1.8.1 43 04/28/2024
1.8.0 43 04/04/2024
1.8.0-rc.1 53 03/28/2024
1.8.0-beta.1 42 03/18/2024
1.7.0 4,927 12/10/2023
1.7.0-rc.1 44 12/07/2023
1.7.0-alpha.1 45 10/17/2023
1.6.0 44 09/06/2023
1.6.0-rc.1 49 08/26/2023
1.6.0-alpha.1 47 07/15/2023
1.5.1 521 06/28/2023
1.5.0 50 06/30/2023
1.5.0-rc.1 48 08/04/2023
1.5.0-alpha.2 47 05/24/2023
1.5.0-alpha.1 47 05/24/2023
1.4.0 43 05/24/2023
1.4.0-rc.4 56 05/24/2023
1.4.0-rc.3 48 05/24/2023
1.4.0-rc.2 47 08/11/2023
1.4.0-rc.1 41 05/24/2023
1.4.0-beta.3 49 07/14/2023
1.4.0-beta.2 52 08/07/2023
1.4.0-beta.1 58 08/18/2023
1.4.0-alpha.2 51 09/10/2022
1.4.0-alpha.1 50 08/21/2022
1.3.2 53 08/05/2023
1.3.1 50 08/15/2023
1.3.0 47 07/11/2022
1.3.0-rc.2 45 08/05/2023
1.3.0-beta.2 50 06/15/2022
1.3.0-beta.1 46 06/15/2022
1.2.0 45 08/19/2023
1.2.0-rc5 46 05/24/2023
1.2.0-rc4 51 08/19/2023
1.2.0-rc3 47 05/24/2023
1.2.0-rc2 44 08/07/2023
1.2.0-rc1 50 05/24/2023
1.2.0-beta2.1 52 10/11/2022
1.2.0-beta1 45 05/24/2023
1.2.0-alpha4 45 08/11/2023
1.2.0-alpha3 56 05/24/2023
1.2.0-alpha2 47 08/04/2023
1.2.0-alpha1 48 08/08/2023
1.1.0 53 05/24/2023
1.1.0-rc1 48 05/24/2023
1.1.0-beta4 42 07/03/2023
1.1.0-beta3 47 05/24/2023
1.1.0-beta2 48 09/04/2022
1.1.0-beta1 46 05/24/2023
1.0.1 50 07/16/2022
1.0.0-rc4 40 05/24/2023
1.0.0-rc3 47 05/24/2023
1.0.0-rc2 45 05/24/2023
1.0.0-rc1.1 45 08/09/2023
0.8.0-beta.1 47 08/28/2022
0.7.0-beta.1 51 08/05/2023
0.6.0-beta.1 45 08/11/2023
0.5.0-beta.2 49 08/10/2023
0.4.0-beta.2 44 08/10/2023
0.3.0-beta.1 51 08/04/2023
0.2.0-alpha.275 42 09/24/2023
0.2.0-alpha.220 52 08/16/2023
0.2.0-alpha.179 46 08/17/2023
0.2.0-alpha.100 41 08/11/2023
0.2.0-alpha.40 52 05/06/2023
0.2.0-alpha.5 44 08/23/2023