OpenTelemetry .NET Automatic Instrumentation
Go to file
Robert Pająk 8fb0af0afa
Add instrument.sh script (#1354)
2022-10-04 06:46:34 +00:00
.config Bump Nuke.Common from 6.1.2 to 6.2.1 in /build/nuke (#1092) 2022-08-23 16:32:55 +00:00
.cspell Add instrument.sh script (#1354) 2022-10-04 06:46:34 +00:00
.github Add instrument.sh script (#1354) 2022-10-04 06:46:34 +00:00
.nuke [POC] Add native tests (#201) 2021-07-20 10:46:07 -07:00
.vscode Spellcheck documentation (#627) 2022-04-25 10:04:54 -07:00
build/nuke Add diagnostic messages and hang dumps for IntegrationTests (#1298) 2022-09-28 16:31:29 -07:00
dev Cleanup Examples.AspNetCoreMvc (#1067) 2022-08-09 15:17:41 -07:00
docs Add instrument.sh script (#1354) 2022-10-04 06:46:34 +00:00
examples Bump OpenTelemetry.Instrumentation.AspNet from 1.0.0-rc9.5 to 1.0.0-rc9.6 in /examples/ConsoleApp.SelfBootstrap (#1305) 2022-09-29 15:06:44 +00:00
src Fix potential null reference exceptions in ActivityHelper (#1328) 2022-10-04 06:24:11 +00:00
test Fix potential null reference exceptions in ActivityHelper (#1328) 2022-10-04 06:24:11 +00:00
.clang-format Forking the DataDog .NET Tracer to seed the OTel .NET Auto-Instrumentation-Agent. 2020-08-20 13:35:02 -07:00
.cspell.json Spellcheck documentation (#627) 2022-04-25 10:04:54 -07:00
.editorconfig dotnet-format check step (#1121) 2022-08-24 22:41:18 -07:00
.gitattributes Verify whole distribution structure (#1156) 2022-09-06 12:15:06 -07:00
.gitignore Add diagnostic messages and hang dumps for IntegrationTests (#1298) 2022-09-28 16:31:29 -07:00
.markdownlint.yaml Update Changelog and MongoDB docs (#635) 2022-04-28 22:54:51 +00:00
.markdownlintignore Improve local documentation validation (#1028) 2022-08-02 16:20:28 -07:00
CHANGELOG.md Replace span.kind tag by ActivityKind (#1321) 2022-10-03 09:22:12 +02:00
Common.props Add copyright header in C# files and improve Stylecop.Analyzer usage (#415) 2022-03-18 08:25:23 +01:00
Directory.Build.props Refactoring (#922) 2022-07-07 08:51:10 +02:00
GlobalSuppressions.cs Add copyright header in C# files and improve Stylecop.Analyzer usage (#415) 2022-03-18 08:25:23 +01:00
LICENSE Initial commit 2020-07-14 20:50:30 -04:00
OpenTelemetry.AutoInstrumentation.DotSettings Rename assemblies to OpenTelemetry.AutoInstrumentation (#363) 2022-02-15 11:49:09 -08:00
OpenTelemetry.AutoInstrumentation.proj Add WCF instrumentation (#1125) 2022-09-13 11:58:24 +02:00
OpenTelemetry.AutoInstrumentation.sln Add test to ensure domain-neutral is working (#1234) 2022-09-21 09:23:50 +00:00
build.cmd [POC] Add OTEL_DOTNET_TRACER_INSTRUMENTATIONS and bump dependencies (#204) 2021-07-29 08:54:30 +02:00
build.ps1 Add restore with retry in Nuke build (#841) 2022-06-14 09:11:48 -07:00
build.sh [POC] Add native tests (#201) 2021-07-20 10:46:07 -07:00
download.sh Add instrument.sh script (#1354) 2022-10-04 06:46:34 +00:00
instrument.sh Add instrument.sh script (#1354) 2022-10-04 06:46:34 +00:00
integrations.json Add ILogger bytecode instrumentation (#1262) 2022-09-27 12:54:25 -07:00
nuget.config Create nuget.config (#120) 2021-04-08 09:21:33 -07:00
opentelemetry-logo-64x64.png Exchange datadog logo files with opentelemetry ones (#64) 2021-03-02 21:02:41 -08:00
opentelemetry-logo-256x256.png Exchange datadog logo files with opentelemetry ones (#64) 2021-03-02 21:02:41 -08:00
package-lock.json Bump cspell-cli from 6.10.0 to 6.12.0 (#1348) 2022-10-03 14:14:16 +00:00
package.json Bump cspell-cli from 6.10.0 to 6.12.0 (#1348) 2022-10-03 14:14:16 +00:00
run-example.sh Introduce OTEL_DOTNET_AUTO_PLUGINS (#1174) 2022-09-09 01:09:41 +00:00
stylecop.json Add copyright header in C# files and improve Stylecop.Analyzer usage (#415) 2022-03-18 08:25:23 +01:00

docs/README.md

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 (0.3.1-beta.1) can be found here.


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

You can find all references in OpenTelemetry.AutoInstrumentation.csproj and OpenTelemetry.AutoInstrumentation.AdditionalDeps/Directory.Build.props.

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:

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 $INSTALL_DIR

You can also use the download.sh script which uses following environment variables as parameters:

Parameter Description Required Default value
DISTRIBUTION Possible values: linux-glibc, linux-musl, macos, windows Yes
INSTALL_DIR Location where binaries are to be installed No ./otel-dotnet-auto
RELEASES_URL GitHub releases URL No https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases
TMPDIR Temporary directory used when downloading the files No $(mktemp -d)
VERSION Version to download No v0.3.1-beta.1
( set -o pipefail
curl -sSfL https://raw.githubusercontent.com/open-telemetry/opentelemetry-dotnet-instrumentation/main/download.sh |
  VERSION=v0.3.1-beta.1 DISTRIBUTION=linux-glibc bash -s )

Instrument a .NET application

Before running your application, set the following environment variables:

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper
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=$INSTALL_DIR/AdditionalDeps
DOTNET_SHARED_STORE=$INSTALL_DIR/store
DOTNET_STARTUP_HOOKS=$INSTALL_DIR/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll
OTEL_DOTNET_AUTO_HOME=$INSTALL_DIR
OTEL_DOTNET_AUTO_INTEGRATIONS_FILE=$INSTALL_DIR/integrations.json

On Windows you need to additionally set:

COR_PROFILER_PATH_32=$INSTALL_DIR/win-x86/OpenTelemetry.AutoInstrumentation.Native.dll
COR_PROFILER_PATH_64=$INSTALL_DIR/win-x64/OpenTelemetry.AutoInstrumentation.Native.dll
CORECLR_PROFILER_PATH_32=$INSTALL_DIR/win-x86/OpenTelemetry.AutoInstrumentation.Native.dll
CORECLR_PROFILER_PATH_64=$INSTALL_DIR/win-x64/OpenTelemetry.AutoInstrumentation.Native.dll

On Linux you need to additionally set:

CORECLR_PROFILER_PATH=$INSTALL_DIR/OpenTelemetry.AutoInstrumentation.Native.so

On macOS you need to additionally set:

CORECLR_PROFILER_PATH=$INSTALL_DIR/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

On .NET (Core), if you don't need bytecode instrumentations, you can unset or remove the following environment variables to not set the .NET CLR Profiler:

COR_ENABLE_PROFILING
COR_PROFILER
COR_PROFILER_PATH_32
COR_PROFILER_PATH_64
CORECLR_ENABLE_PROFILING
CORECLR_PROFILER
CORECLR_PROFILER_PATH
CORECLR_PROFILER_PATH_32
CORECLR_PROFILER_PATH_64
OTEL_DOTNET_AUTO_INTEGRATIONS_FILE

You can also use the instrument.sh script which uses following environment variables as parameters:

Parameter Description Required Default value
DISTRIBUTION Possible values: linux-glibc, linux-musl, macos, windows Yes
ENABLE_PROFILING Whether to set the .NET CLR Profiler, possible values: true, false No true
INSTALL_DIR Location where binaries are to be installed No ./otel-dotnet-auto

On macOS coreutils is required.

curl -fL https://raw.githubusercontent.com/open-telemetry/opentelemetry-dotnet-instrumentation/main/instrument.sh -O
DISTRIBUTION=linux-glibc source ./instrument.sh
OTEL_SERVICE_NAME=myapp dotnet run

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.