OpenTelemetry .NET Automatic Instrumentation
Go to file
Piotr Kiełkowicz b4a4120bbd
Enable/disable log instrumentations (#1475)
* Introduce instrumentation types

* extend generator

* support for disabling logs bytecode integrations

* update documentation

* change LoggingBuilder instrumentation name to ILogger

* Support managing log instrumentation in managed code

* update changelog

* PR feedback - config

* add LogsNoneInstrumentations test

Co-authored-by: Chris Ventura <45495992+nrcventura@users.noreply.github.com>
2022-10-21 13:31:53 -07: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 Bump actions/download-artifact from 3.0.0 to 3.0.1 (#1483) 2022-10-21 16:23:03 +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 Bump Nuget.CommandLine from 6.3.0 to 6.3.1 in /build (#1406) 2022-10-12 06:33:54 +02:00
dev Use jaegertracing/all-in-one:1.38.1 (#1399) 2022-10-11 05:01:03 +00:00
docker Add GH job for testing the Shell scripts on Alpine (#1402) 2022-10-12 04:57:36 +00:00
docs Enable/disable log instrumentations (#1475) 2022-10-21 13:31:53 -07:00
examples Bump MongoDB.Driver from 2.17.1 to 2.18.0 in /examples/AspNetCoreMvc (#1431) 2022-10-18 09:13:10 +02:00
nuget OpenTelemetry.AutoInstrumentation NuGet package (#1368) 2022-10-13 12:05:06 -07:00
src Enable/disable log instrumentations (#1475) 2022-10-21 13:31:53 -07:00
test Enable/disable log instrumentations (#1475) 2022-10-21 13:31:53 -07:00
tools/IntegrationsJsonGenerator Enable/disable log instrumentations (#1475) 2022-10-21 13:31:53 -07: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 Enable/disable log instrumentations (#1475) 2022-10-21 13:31:53 -07: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 Integrations json file generator (#1466) 2022-10-20 07:50:36 +00:00
OpenTelemetry.Dotnet.Auto.psm1 Refine PowerShell install module (#1473) 2022-10-21 09:25:01 +02:00
build.cmd [POC] Add OTEL_DOTNET_TRACER_INSTRUMENTATIONS and bump dependencies (#204) 2021-07-29 08:54:30 +02:00
build.ps1 Repository organization cleanup (#1391) 2022-10-10 21:18:21 +00:00
build.sh Repository organization cleanup (#1391) 2022-10-10 21:18:21 +00:00
download.sh Calulate default OS_TYPE (#1403) 2022-10-12 05:28:58 +00:00
instrument.sh Calulate default OS_TYPE (#1403) 2022-10-12 05:28:58 +00:00
integrations.json Enable/disable log instrumentations (#1475) 2022-10-21 13:31:53 -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 Ensure ./run-example.sh adds bytecode instr. (#1383) 2022-10-10 11:31:53 +02: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

Instrument a .NET application

When running your application, make sure to:

  1. Set the resources.
  2. Set the environment variables from the table below.
Environment variable .NET version Value
COR_ENABLE_PROFILING .NET Framework 1
COR_PROFILER .NET Framework {918728DD-259F-4A6A-AC2B-B85E1B658318}
COR_PROFILER_PATH_32 .NET Framework $INSTALL_DIR/win-x86/OpenTelemetry.AutoInstrumentation.Native.dll
COR_PROFILER_PATH_64 .NET Framework $INSTALL_DIR/win-x64/OpenTelemetry.AutoInstrumentation.Native.dll
CORECLR_ENABLE_PROFILING .NET (Core) 1
CORECLR_PROFILER .NET (Core) {918728DD-259F-4A6A-AC2B-B85E1B658318}
CORECLR_PROFILER_PATH .NET (Core) on Linux $INSTALL_DIR/OpenTelemetry.AutoInstrumentation.Native.so
CORECLR_PROFILER_PATH .NET (Core) on macOS $INSTALL_DIR/OpenTelemetry.AutoInstrumentation.Native.dylib
CORECLR_PROFILER_PATH_32 .NET (Core) on Windows $INSTALL_DIR/win-x86/OpenTelemetry.AutoInstrumentation.Native.dll
CORECLR_PROFILER_PATH_64 .NET (Core) on Windows $INSTALL_DIR/win-x64/OpenTelemetry.AutoInstrumentation.Native.dll
DOTNET_ADDITIONAL_DEPS .NET (Core) $INSTALL_DIR/AdditionalDeps
DOTNET_SHARED_STORE .NET (Core) $INSTALL_DIR/store
DOTNET_STARTUP_HOOKS .NET (Core) $INSTALL_DIR/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll
OTEL_DOTNET_AUTO_HOME All versions $INSTALL_DIR
OTEL_DOTNET_AUTO_INTEGRATIONS_FILE All versions $INSTALL_DIR/integrations.json

Some settings can be omitted on .NET (Core). For more information, see config.md.

Shell scripts

You can install OpenTelemetry .NET Automatic Instrumentation and instrument your .NET application using the provided Shell scripts. Example usage:

curl -sSfL https://raw.githubusercontent.com/open-telemetry/opentelemetry-dotnet-instrumentation/v0.3.1-beta.1/download.sh -O
sh ./download.sh
. $HOME/.otel-dotnet-auto/instrument.sh
OTEL_SERVICE_NAME=myapp OTEL_RESOURCE_ATTRIBUTES=deployment.environment=staging,service.version=1.0.0 dotnet run

download.sh script uses environment variables as parameters:

Parameter Description Required Default value
OTEL_DOTNET_AUTO_HOME Location where binaries are to be installed No $HOME/.otel-dotnet-auto
OS_TYPE Possible values: linux-glibc, linux-musl, macos, windows No Calculated
TMPDIR Temporary directory used when downloading the files No $(mktemp -d)
VERSION Version to download No v0.3.1-beta.1

instrument.sh script uses environment variables as parameters:

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

On macOS coreutils is required.

PowerShell module (Windows)

On Windows, you can install OpenTelemetry .NET Automatic Instrumentation and instrument your .NET application using the provided PowerShell module. Example usage:

# Download and import the module
$module_url = "https://raw.githubusercontent.com/open-telemetry/opentelemetry-dotnet-instrumentation/v0.3.1-beta.1/OpenTelemetry.Dotnet.Auto.psm1"
$download_path = Join-Path $env:temp "OpenTelemetry.Dotnet.Auto.psm1"
Invoke-WebRequest -Uri $module_url -OutFile $download_path
Import-Module $download_path

# Install core files
Install-OpenTelemetryCore

# Setup IIS instrumentation
Register-OpenTelemetryForIIS

# Setup your Windows Service instrumentation
Register-OpenTelemetryForWindowsService -WindowsServiceName "MyServiceName" -OTelServiceName "MyServiceDisplayName"

# Setup environment to start instrumentation from the current PowerShell session
Register-OpenTelemetryForCurrentSession -OTelServiceName "MyServiceDisplayName"

# Get current installation location
Get-OpenTelemetryInstallDirectory

# List all available commands
Get-Command -Module install

# Get command's usage information
Get-Help Install-OpenTelemetryCore -Detailed

⚠️ Registering for IIS and Windows Service will perform a service restart.

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.