Skip to content

Commit

Permalink
Merge branch 'main' into clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Feb 2, 2023
2 parents 7987764 + fe24131 commit 655b14c
Show file tree
Hide file tree
Showing 66 changed files with 878 additions and 896 deletions.
12 changes: 12 additions & 0 deletions .cspell/other.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ tracesexporter
unencrypted
UNENCRYPTEDSUPPORT
vcpkg
ILOGGER
NSERVICEBUS
NETRUNTIME
HTTPCLIENT
STACKEXCHANGEREDIS
SQLCLIENT
NSERVICEBUS
MYSQLDATA
MASSTRANSIT
HTTPCLIENT
GRPCNETCLIENT
ENTITYFRAMEWORKCORE
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ This beta release is built on top of [OpenTelemetry .NET](https://github.com/ope
to `linux-musl-x64` for Linux musl and
`OpenTelemetry.AutoInstrumentation.Native.dylib`
to `osx-x64` for MacOS.
- Change the way to manage enabled instrumentations. The following environmental
variables:
- `OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS`,
- `OTEL_DOTNET_AUTO_TRACES_DISABLED_INSTRUMENTATIONS`,
- `OTEL_DOTNET_AUTO_METRICS_ENABLED_INSTRUMENTATIONS`,
- `OTEL_DOTNET_AUTO_METRICS_DISABLED_INSTRUMENTATIONS`,
- `OTEL_DOTNET_AUTO_LOGS_ENABLED_INSTRUMENTATIONS`,
- `OTEL_DOTNET_AUTO_LOGS_DISABLED_INSTRUMENTATIONS`

are replaced by:

- `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED`,
- `OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED`,
- `OTEL_DOTNET_AUTO_TRACES_{0}_INSTRUMENTATION_ENABLED`,
- `OTEL_DOTNET_AUTO_METRICS_INSTRUMENTATION_ENABLED`,
- `OTEL_DOTNET_AUTO_METRICS_{0}_INSTRUMENTATION_ENABLED`,
- `OTEL_DOTNET_AUTO_LOGS_INSTRUMENTATION_ENABLED`,
- `OTEL_DOTNET_AUTO_LOGS_{0}_INSTRUMENTATION_ENABLED`.

- Change instrumentation id for ASP.NET Core traces and metrics instrumentation
from `AspNet` to `ASPNETCORE`.

### Deprecated

Expand Down
107 changes: 107 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,110 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

---------------------------------------------------------------------------

OpenTelemetry .NET Automatic Instrumentation components

OpenTelemetry .NET Automatic Instrumentation project contains components with
separate copyright notices and license terms:

Library Google.Protobuf is under the following copyright:
Copyright 2008 Google Inc. All rights reserved under BSD-3-Clause license
(https://github.com/protocolbuffers/protobuf/blob/main/LICENSE).

Libraries
- Google.Protobuf,
- Grpc.Net.Common,
- Grpc.Net.Client
are under the following copyright:
Copyright 2019 The gRPC Authors under Apache License Version 2.0
(https://github.com/grpc/grpc-dotnet/blob/master/LICENSE).

Libraries
- OpenTelemetry.Api,
- OpenTelemetry.Exporter.Console,
- OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs,
- OpenTelemetry.Exporter.OpenTelemetryProtocol,
- OpenTelemetry.Exporter.Prometheus.HttpListener,
- OpenTelemetry.Exporter.Zipkin,
- OpenTelemetry.Extensions.DependencyInjection,
- OpenTelemetry.Extensions.Propagators,
- OpenTelemetry.Instrumentation.AspNetCore,
- OpenTelemetry.Instrumentation.GrpcNetClient,
- OpenTelemetry.Instrumentation.Http,
- OpenTelemetry.Instrumentation.SqlClient,
- OpenTelemetry.Shims.OpenTracing,
- OpenTelemetry
are under the following copyright:
Copyright The OpenTelemetry Authors under Apache License Version 2.0
(https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/LICENSE).

Libraries
- OpenTelemetry.Api,
- OpenTelemetry.Instrumentation.EntityFrameworkCore,
- OpenTelemetry.Instrumentation.MySqlData,
- OpenTelemetry.Instrumentation.Process,
- OpenTelemetry.Instrumentation.Quartz,
- OpenTelemetry.Instrumentation.Runtime,
- OpenTelemetry.Instrumentation.StackExchangeRedis,
- OpenTelemetry.Instrumentation.Wcf
are under the following copyright:
Copyright The OpenTelemetry Authors under Apache License Version 2.0
(https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/main/LICENSE).

Library OpenTracing is under the following copyright:
Copyright The OpenTracing Authors under Apache License Version 2.0
(https://github.com/opentracing/opentracing-csharp/blob/master/LICENSE).

Libraries
- System.Diagnostics.DiagnosticSource,
- System.Security.Permissions,
- Microsoft.Extensions.Configuration.Abstractions,
- Microsoft.Extensions.Configuration.Binder,
- Microsoft.Extensions.Configuration.EnvironmentVariables,
- Microsoft.Extensions.Configuration,
- Microsoft.Extensions.DependencyInjection.Abstractions,
- Microsoft.Extensions.DependencyInjection,
- Microsoft.Extensions.Logging.Abstractions,
- Microsoft.Extensions.Logging.Configuration,
- Microsoft.Extensions.Logging,
- Microsoft.Extensions.Options.ConfigurationExtensions,
- Microsoft.Extensions.Options,
- Microsoft.Extensions.Primitives
are under the following copyright:
Copyright (c) .NET Foundation and Contributors under the MIT License (MIT)
(https://github.com/dotnet/runtime/blob/main/LICENSE.TXT).

Libraries
- System.Private.ServiceModel,
- System.ServiceModel.Primitives,
- System.ServiceModel
are under the following copyright:
Copyright (c) .NET Foundation and Contributors under the MIT License (MIT)
(https://github.com/dotnet/wcf/blob/main/LICENSE.TXT).

Library DnsClient is under the following copyright:
Copyright The DnsClient.NET Authors under Apache License Version 2.0
(https://github.com/opentracing/opentracing-csharp/blob/master/LICENSE).

Libraries
- MongoDB.Bson,
- MongoDB.Driver.Core,
- libzstd,
- snappy32,
- snappy64,
- MongoDB.Libmongocrypt,
- libmongocrypt,
- mongocrypt
are under the following copyright:
Copyright 2010-present MongoDB Inc. under Apache License Version 2.0
(https://github.com/mongodb/mongo-csharp-driver/blob/master/License.txt).

Library MongoDB.Driver.Core.Extensions.DiagnosticSources is under the following copyright:
Copyright MongoDB.Driver.Core.Extensions.DiagnosticSources Authors under Apache License Version 2.0
(https://github.com/jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources/blob/master/LICENSE).

Library SharpCompress is under the following copyright:
Copyright (c) 2014 Adam Hathcock under the MIT License (MIT)
(https://github.com/adamhathcock/sharpcompress/blob/master/LICENSE.txt).
8 changes: 6 additions & 2 deletions OpenTelemetry.DotNet.Auto.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ function Install-OpenTelemetryCore() {
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
$publish = New-Object System.EnterpriseServices.Internal.Publish
$dlls = Get-ChildItem -Path $installDir\netfx\ -Filter *.dll -File
foreach ($dll in $dlls) {
$publish.GacInstall($dll.FullName)
for ($i = 0; $i -le $dlls.Count; $i++) {
$percentageComplete = $i / $dlls.Count * 100
Write-Progress -Activity "Registering .NET Framweworks dlls in GAC" `
-Status "Module $($i+1) out of $($dlls.Count). Installing $($dlls[$i].Name):" `
-PercentComplete $percentageComplete
$publish.GacInstall($dlls[$i].FullName)
}
}
catch {
Expand Down
8 changes: 8 additions & 0 deletions build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ partial class Build
.EnableNoRestore()
.SetFramework(TargetFramework.NET6_0)
.SetOutput(TracerHomeDirectory / MapToFolderOutput(TargetFramework.NET6_0)));

// Remove non-library files
TracerHomeDirectory.GlobFiles("**/*.xml").ForEach(DeleteFile);
(TracerHomeDirectory / "net").GlobFiles("*.json").ForEach(DeleteFile);
if (IsWin)
{
(TracerHomeDirectory / "netfx").GlobFiles("*.json").ForEach(DeleteFile);
}
});

Target PublishNativeProfiler => _ => _
Expand Down
1 change: 0 additions & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void DeleteReparsePoints(string path)
.After(Clean)
.DependsOn(CreateRequiredDirectories)
.DependsOn(Restore)
.DependsOn(GenerateNetFxTransientDependencies)
.DependsOn(CompileManagedSrc)
.DependsOn(PublishManagedProfiler)
.DependsOn(GenerateNetFxAssemblyRedirectionSource)
Expand Down
87 changes: 57 additions & 30 deletions dev/envvars.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
#!/bin/bash

case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
linux*)
if [ "$(ldd /bin/ls | grep -m1 'musl')" ]; then
DOTNET_RUNTIME_ID="linux-musl"
else
DOTNET_RUNTIME_ID="linux-x64"
fi
# guess OS_TYPE if not provided
OS_TYPE=${OS_TYPE:-}
if [ -z "$OS_TYPE" ]; then
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
cygwin_nt*|mingw*|msys_nt*)
OS_TYPE="windows"
;;
linux*)
if [ "$(ldd /bin/ls | grep -m1 'musl')" ]; then
OS_TYPE="linux-musl"
else
OS_TYPE="linux-glibc"
fi
;;
darwin*)
OS_TYPE="macos"
;;
esac
fi

# validate input
case "$OS_TYPE" in
"linux-glibc")
DOTNET_RUNTIME_ID="linux-x64"
;;
"linux-musl")
DOTNET_RUNTIME_ID="linux-musl-x64"
;;
darwin*)
"macos")
DOTNET_RUNTIME_ID="osx-x64"
;;
"windows")
;;
*)
echo "Set the operating system type using the OS_TYPE environment variable. Supported values: linux-glibc, linux-musl, macos, windows." >&2
return 2
;;
esac

uname_os() {
Expand Down Expand Up @@ -46,28 +72,6 @@ SUFIX=$(native_sufix)
OS=$(uname_os)
ENABLE_PROFILING=${ENABLE_PROFILING:-1}

# Enable .NET Framework Profiling API
if [ "$OS" == "windows" ]
then
export COR_ENABLE_PROFILING="${ENABLE_PROFILING}"
export COR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"
export COR_PROFILER_PATH="${CURDIR}/bin/tracer-home/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
# Set paths for both bitness on Windows, see https://docs.microsoft.com/en-us/dotnet/core/run-time-config/debugging-profiling#profiler-location
export COR_PROFILER_PATH_64="${CURDIR}/bin/tracer-home/win-x64/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
export COR_PROFILER_PATH_32="${CURDIR}/bin/tracer-home/win-x86/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
fi

# Enable .NET Core Profiling API
export CORECLR_ENABLE_PROFILING="${ENABLE_PROFILING}"
export CORECLR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"
export CORECLR_PROFILER_PATH="${CURDIR}/bin/tracer-home/$DOTNET_RUNTIME_ID/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
if [ "$OS" == "windows" ]
then
# Set paths for both bitness on Windows, see https://docs.microsoft.com/en-us/dotnet/core/run-time-config/debugging-profiling#profiler-location
export CORECLR_PROFILER_PATH_64="${CURDIR}/bin/tracer-home/win-x64/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
export CORECLR_PROFILER_PATH_32="${CURDIR}/bin/tracer-home/win-x86/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
fi

# Configure .NET Core runtime
export DOTNET_ADDITIONAL_DEPS="${CURDIR}/bin/tracer-home/AdditionalDeps"
export DOTNET_SHARED_STORE="${CURDIR}/bin/tracer-home/store"
Expand All @@ -87,3 +91,26 @@ export OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES=${OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES:-
export OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED=${OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED:-true}
export OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED=${OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED:-true}
export OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED=${OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED:-true}

# Enable .NET Framework Profiling API
if [ "$OS" == "windows" ]
then
export COR_ENABLE_PROFILING="${ENABLE_PROFILING}"
export COR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"
export COR_PROFILER_PATH="${CURDIR}/bin/tracer-home/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
# Set paths for both bitness on Windows, see https://docs.microsoft.com/en-us/dotnet/core/run-time-config/debugging-profiling#profiler-location
export COR_PROFILER_PATH_64="${CURDIR}/bin/tracer-home/win-x64/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
export COR_PROFILER_PATH_32="${CURDIR}/bin/tracer-home/win-x86/OpenTelemetry.AutoInstrumentation.Native.${SUFIX}"
fi

# Enable .NET Core Profiling API
export CORECLR_ENABLE_PROFILING="${ENABLE_PROFILING}"
export CORECLR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"
if [ "$OS_TYPE" == "windows" ]
then
# Set paths for both bitness on Windows, see https://docs.microsoft.com/en-us/dotnet/core/run-time-config/debugging-profiling#profiler-location
export CORECLR_PROFILER_PATH_64="$OTEL_DOTNET_AUTO_HOME/win-x64/OpenTelemetry.AutoInstrumentation.Native.$SUFIX"
export CORECLR_PROFILER_PATH_32="$OTEL_DOTNET_AUTO_HOME/win-x86/OpenTelemetry.AutoInstrumentation.Native.$SUFIX"
else
export CORECLR_PROFILER_PATH="$OTEL_DOTNET_AUTO_HOME/$DOTNET_RUNTIME_ID/OpenTelemetry.AutoInstrumentation.Native.$SUFIX"
fi
19 changes: 19 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ See [config.md#instrumented-libraries-and-frameworks](config.md#instrumented-lib

## Get started

### Considerations on scope

Currently, instrumenting [`self-contained`](https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained)
applications is not supported. Note that a `self-contained` applications is
automatically generated in .NET 7.0 whenever the `dotnet publish` or `dotnet build`
command is used with a Runtime Identifier (RID) parameter, for example when `-r`
or `--runtime` is used when running the command. The `dotnet` CLI is
a `self-contained` application and it's incompatible with automatic instrumentation.

To build and launch an instrumented application, take the following into account:

- Don't set the automatic instrumentation environment variables in the same session
used to run the `dotnet` tool.
- Don't launch the application to be instrumented using `dotnet run` or
`dotnet <dll>`. Build the application in an isolated shell, without the
automatic instrumentation environment variables set, and use a separate
session with the automatic instrumentation variables to directly launch
the executable.

### Install

Download and extract the appropriate binaries from
Expand Down
Loading

0 comments on commit 655b14c

Please sign in to comment.