OpenTelemetry 1.11.0-rc.1
OpenTelemetry .NET SDK
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"
}
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
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.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.LogLevel
is the lowest level of the events to be captured. It has to be one of the values of theEventLevel
enum. The level signifies the severity of an event. Lower severity levels encompass higher severity levels. For example,Warning
includes theError
andCritical
levels.
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 NUL
s 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 |
---|---|
Honeycomb.OpenTelemetry
Honeycomb's OpenTelemetry SDK
|
12 |
Microsoft.Extensions.Telemetry
Provides canonical implementations of telemetry abstractions
|
11 |
OpenTelemetry.Exporter.Console
Console exporter for OpenTelemetry .NET
|
12 |
OpenTelemetry.Exporter.OpenTelemetryProtocol
OpenTelemetry protocol exporter for OpenTelemetry .NET
|
30 |
OpenTelemetry.Exporter.Zipkin
Zipkin exporter for OpenTelemetry .NET
|
11 |
OpenTelemetry.Exporter.Zipkin
Zipkin exporter for OpenTelemetry .NET
|
12 |
OpenTelemetry.Instrumentation.AspNet
ASP.NET instrumentation for OpenTelemetry .NET
|
11 |
OpenTelemetry.Instrumentation.GrpcNetClient
gRPC for .NET client instrumentation for OpenTelemetry .NET
|
12 |
OpenTelemetry.Instrumentation.GrpcNetClient
gRPC for .NET client instrumentation for OpenTelemetry .NET
|
14 |
OpenTelemetry.Instrumentation.Http
Http instrumentation for OpenTelemetry .NET
|
12 |
OpenTelemetry.Instrumentation.Http
Http instrumentation for OpenTelemetry .NET
|
14 |
RocketMQ.Client
.NET Client for Apache RocketMQ
|
11 |
RocketMQ.Client
.NET Client for Apache RocketMQ
|
12 |
RocketMQ.Client
.NET Client for Apache RocketMQ
|
17 |
RocketMQ.Client
.NET Client for Apache RocketMQ
|
32 |
.NET Framework 4.6.2
- OpenTelemetry.Api.ProviderBuilderExtensions (>= 1.11.0-rc.1)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 9.0.0)
.NET Standard 2.1
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 9.0.0)
- OpenTelemetry.Api.ProviderBuilderExtensions (>= 1.11.0-rc.1)
.NET Standard 2.0
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- OpenTelemetry.Api.ProviderBuilderExtensions (>= 1.11.0-rc.1)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 9.0.0)
.NET 9.0
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- OpenTelemetry.Api.ProviderBuilderExtensions (>= 1.11.0-rc.1)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 9.0.0)
.NET 8.0
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 9.0.0)
- OpenTelemetry.Api.ProviderBuilderExtensions (>= 1.11.0-rc.1)
Version | Downloads | Last updated |
---|---|---|
1.11.0-rc.1 | 1 | 12/15/2024 |
1.10.0 | 7 | 11/14/2024 |
1.10.0-rc.1 | 6 | 11/04/2024 |
1.10.0-beta.1 | 5 | 11/28/2024 |
1.9.0 | 3 | 11/28/2024 |
1.9.0-rc.1 | 3 | 11/14/2024 |
1.9.0-alpha.1 | 7 | 06/01/2024 |
1.8.1 | 8 | 04/24/2024 |
1.8.0 | 11 | 06/01/2024 |
1.8.0-rc.1 | 5 | 06/01/2024 |
1.8.0-beta.1 | 6 | 06/01/2024 |
1.7.0 | 5 | 06/01/2024 |
1.7.0-rc.1 | 9 | 06/01/2024 |
1.7.0-alpha.1 | 7 | 06/01/2024 |
1.6.0 | 5 | 06/01/2024 |
1.6.0-rc.1 | 10 | 06/01/2024 |
1.6.0-alpha.1 | 8 | 06/01/2024 |
1.5.1 | 9 | 07/20/2023 |
1.5.0 | 7 | 06/01/2024 |
1.5.0-rc.1 | 5 | 06/01/2024 |
1.5.0-alpha.2 | 6 | 06/01/2024 |
1.5.0-alpha.1 | 9 | 05/06/2024 |
1.4.0 | 7 | 02/22/2024 |
1.4.0-rc.4 | 7 | 06/01/2024 |
1.4.0-rc.3 | 8 | 06/01/2024 |
1.4.0-rc.2 | 9 | 06/01/2024 |
1.4.0-rc.1 | 6 | 06/01/2024 |
1.4.0-beta.3 | 6 | 06/01/2024 |
1.4.0-beta.2 | 8 | 06/01/2024 |
1.4.0-beta.1 | 7 | 06/01/2024 |
1.4.0-alpha.2 | 6 | 06/01/2024 |
1.4.0-alpha.1 | 8 | 05/06/2024 |
1.3.2 | 7 | 06/01/2024 |
1.3.1 | 33 | 10/26/2023 |
1.3.0 | 6 | 06/01/2024 |
1.3.0-rc.2 | 8 | 05/06/2024 |
1.3.0-beta.2 | 6 | 06/01/2024 |
1.3.0-beta.1 | 9 | 06/01/2024 |
1.2.0 | 9 | 06/01/2024 |
1.2.0-rc5 | 7 | 06/01/2024 |
1.2.0-rc4 | 7 | 06/01/2024 |
1.2.0-rc3 | 7 | 06/01/2024 |
1.2.0-rc2 | 10 | 06/01/2024 |
1.2.0-rc1 | 6 | 06/01/2024 |
1.2.0-beta2.1 | 7 | 06/01/2024 |
1.2.0-beta1 | 10 | 06/01/2024 |
1.2.0-alpha4 | 5 | 06/01/2024 |
1.2.0-alpha3 | 6 | 06/01/2024 |
1.2.0-alpha2 | 11 | 06/01/2024 |
1.2.0-alpha1 | 7 | 06/01/2024 |
1.1.0 | 8 | 06/01/2024 |
1.1.0-rc1 | 7 | 06/01/2024 |
1.1.0-beta4 | 6 | 06/01/2024 |
1.1.0-beta3 | 9 | 06/01/2024 |
1.1.0-beta2 | 7 | 06/01/2024 |
1.1.0-beta1 | 7 | 06/01/2024 |
1.0.1 | 6 | 06/01/2024 |
1.0.0-rc4 | 6 | 06/01/2024 |
1.0.0-rc3 | 6 | 06/01/2024 |
1.0.0-rc2 | 9 | 06/01/2024 |
1.0.0-rc1.1 | 11 | 06/01/2024 |
0.8.0-beta.1 | 2 | 11/28/2024 |
0.7.0-beta.1 | 6 | 06/01/2024 |
0.6.0-beta.1 | 10 | 05/16/2023 |
0.5.0-beta.2 | 5 | 06/01/2024 |
0.4.0-beta.2 | 8 | 05/06/2024 |
0.3.0-beta.1 | 6 | 06/01/2024 |
0.2.0-alpha.275 | 5 | 06/01/2024 |
0.2.0-alpha.220 | 5 | 06/01/2024 |
0.2.0-alpha.179 | 4 | 06/01/2024 |
0.2.0-alpha.100 | 7 | 06/01/2024 |
0.2.0-alpha.40 | 8 | 06/01/2024 |
0.2.0-alpha.5 | 3 | 06/01/2024 |