All Projects → open-telemetry → opentelemetry-dotnet-instrumentation

open-telemetry / opentelemetry-dotnet-instrumentation

Licence: Apache-2.0 license
OpenTelemetry .NET Automatic Instrumentation

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
C#
18002 projects
CMake
9771 projects
perl
6916 projects
Pawn
127 projects

OpenTelemetry .NET Automatic Instrumentation

Slack

This project adds OpenTelemetry instrumentation to .NET applications without having to modify their source code.


⚠️ The following documentation refers to the in-development version of OpenTelemetry .NET Automatic Instrumentation. Docs for the latest version (v0.1.0-beta.1) can be found here.


OpenTelemetry .NET Automatic Instrumentation is built on top of OpenTelemetry .NET:

To automatically instrument applications, the OpenTelemetry .NET Automatic Instrumentation does the following:

  1. Injects and configures the OpenTelemetry .NET SDK into the application.
  2. Adds OpenTelemetry Instrumentation to key packages and APIs used by the application.

You can enable the OpenTelemetry .NET Automatic Instrumentation as a .NET Profiler to inject additional instrumentations of this project at runtime, using a technique known as monkey-patching. When enabled, the OpenTelemetry .NET Automatic Instrumentation generates traces for libraries that don't already generate traces using the OpenTelemetry .NET SDK.

See the examples for demonstrations of different instrumentation scenarios covered by the OpenTelemetry .NET Automatic Instrumentation.

See design.md for an architectural overview.

Status

This project is in the early stages of development. The project board shows the current work in progress.

Project versioning information and stability guarantees can be found in the versioning documentation.

⚠️ We need you! ⚠️

Please, give us your feedback (in whatever form you like).

You can do this by submitting a GitHub issue.

You may also prefer writing on Slack. If you are new, you can create a CNCF Slack account here.

See CONTRIBUTING.md for more information.

Compatibility

OpenTelemetry .NET Automatic Instrumentation attempts to work with all officially supported operating systems and versions of .NET (Core), and .NET Framework.

Versions lower than .NET Framework 4.6.2 are not supported.

CI tests run against the following operating systems:

  • Microsoft Windows Server 2022
  • macOS Catalina 10.15
  • Ubuntu 20.04 LTS

Instrumented libraries and frameworks

See config.md#instrumented-libraries-and-frameworks.

Get started

Install

Download and extract the appropriate binaries from the latest release.

The path where you put the binaries is referenced as %InstallationLocation%

On Linux, you can optionally create the default log directory after installation by running the following commands:

sudo mkdir -p /var/log/opentelemetry/dotnet
sudo chmod a+rwx /var/log/opentelemetry/dotnet

Instrument a .NET application

Before running your application, set the following environment variables:

COR_ENABLE_PROFILING=1
COR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}
DOTNET_ADDITIONAL_DEPS=%InstallationLocation%/AdditionalDeps
DOTNET_SHARED_STORE=%InstallationLocation%/store
DOTNET_STARTUP_HOOKS=%InstallationLocation%/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll
OTEL_DOTNET_AUTO_HOME=%InstallationLocation%
OTEL_DOTNET_AUTO_INTEGRATIONS_FILE=%InstallationLocation%/integrations.json

On Windows you need to additionally set:

COR_PROFILER_PATH_64=%InstallationLocation%/win-x64/OpenTelemetry.AutoInstrumentation.Native.dll
COR_PROFILER_PATH_32=%InstallationLocation%/win-x86/OpenTelemetry.AutoInstrumentation.Native.dll
CORECLR_PROFILER_PATH_64=%InstallationLocation%/win-x64/OpenTelemetry.AutoInstrumentation.Native.dll
CORECLR_PROFILER_PATH_32=%InstallationLocation%/win-x86/OpenTelemetry.AutoInstrumentation.Native.dll

On Linux you need to additionally set:

CORECLR_PROFILER_PATH=%InstallationLocation%/OpenTelemetry.AutoInstrumentation.Native.so

On macOS you need to additionally set:

CORECLR_PROFILER_PATH=%InstallationLocation%/OpenTelemetry.AutoInstrumentation.Native.dylib

Configure application's resources. For example:

OTEL_SERVICE_NAME=my-service
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=staging,service.version=1.0.0

Enable desired library instrumentations using OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS and OTEL_DOTNET_AUTO_METRICS_ENABLED_INSTRUMENTATIONS environment variables. For example:

OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS=AspNet,HttpClient
OTEL_DOTNET_AUTO_METRICS_ENABLED_INSTRUMENTATIONS=NetRuntime

Instrument a Windows Service running a .NET application

See windows-service-instrumentation.md.

Instrument an ASP.NET application deployed on IIS

See iis-instrumentation.md.

Configuration

See config.md.

Manual instrumentation

See manual-instrumentation.md.

Troubleshooting

See troubleshooting.md.

Contributing

See CONTRIBUTING.md.

Community Roles

Maintainers (@open-telemetry/dotnet-instrumentation-maintainers):

Approvers (@open-telemetry/dotnet-instrumentation-approvers):

Emeritus Maintainer/Approver/Triager:

Learn more about roles in the community repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].