diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3e9a63dc4f..ee757acca1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,104 +1,31 @@ version: 2 updates: - # Dependency notifications for vendored libraries - - package-ecosystem: "nuget" - directory: "/honeypot" - schedule: - interval: "daily" + + - package-ecosystem: github-actions + directory: / labels: - - "dependencies" - - "area:vendors" - ignore: - - dependency-name: "MessagePack" # Locked at a version that supports our net452 build target - open-pull-requests-limit: 0 # disable version updates - # Src libraries - - package-ecosystem: "nuget" - directory: "/src/Datadog.Trace" + - dependencies + - actions schedule: - interval: "daily" - labels: - - "dependencies" - - "area:tracer" - ignore: - ### Start Datadog.Trace.csproj ignored dependencies - # DiagnosticSource is kept at the lowest supported version for widest compatibility - - dependency-name: "System.Diagnostics.DiagnosticSource" - - # AspNetCore reference libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "Microsoft.AspNetCore.Hosting.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Mvc.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Routing" + day: sunday + interval: weekly - # DuckTyping libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "System.Reflection.Emit" - - dependency-name: "System.Reflection.Emit.Lightweight" - ### End Datadog.Trace.csproj ignored dependencies - open-pull-requests-limit: 0 # disable version updates - - package-ecosystem: "nuget" - directory: "/src/Datadog.Trace.ClrProfiler.Managed" - schedule: - interval: "daily" + - package-ecosystem: nuget + directory: /build/nuke labels: - - "dependencies" - - "area:integrations" - ignore: - ### Start Datadog.Trace.csproj ignored dependencies - # DiagnosticSource is kept at the lowest supported version for widest compatibility - - dependency-name: "System.Diagnostics.DiagnosticSource" - - # AspNetCore reference libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "Microsoft.AspNetCore.Hosting.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Mvc.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Routing" - - # DuckTyping libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "System.Reflection.Emit" - - dependency-name: "System.Reflection.Emit.Lightweight" - ### End Datadog.Trace.csproj ignored dependencies - # Lock Microsoft.Build.Framework for widest compatibility when instrumenting builds - - dependency-name: "Microsoft.Build.Framework" - open-pull-requests-limit: 0 # disable version updates - - package-ecosystem: "nuget" - directory: "/src/Datadog.Trace.OpenTracing" + - dependencies schedule: - interval: "daily" - labels: - - "dependencies" - - "area:opentracing" - ignore: - ### Start Datadog.Trace.csproj ignored dependencies - # DiagnosticSource is kept at the lowest supported version for widest compatibility - - dependency-name: "System.Diagnostics.DiagnosticSource" - - # AspNetCore reference libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "Microsoft.AspNetCore.Hosting.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Mvc.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Routing" + day: sunday + interval: weekly - # DuckTyping libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "System.Reflection.Emit" - - dependency-name: "System.Reflection.Emit.Lightweight" - ### End Datadog.Trace.csproj ignored dependencies - open-pull-requests-limit: 0 # disable version updates - - package-ecosystem: "nuget" - directory: "/src/Datadog.Trace.BenchmarkDotNet" - schedule: - interval: "daily" + - package-ecosystem: nuget + directory: /src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed labels: - - "dependencies" - - "area:benchmarks" + - dependencies ignore: - ### Start Datadog.Trace.csproj ignored dependencies - # DiagnosticSource is kept at the lowest supported version for widest compatibility - - dependency-name: "System.Diagnostics.DiagnosticSource" - - # AspNetCore reference libraries are kept at the lowest supported version for compatibility on netstandard2.0 - - dependency-name: "Microsoft.AspNetCore.Hosting.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Mvc.Abstractions" - - dependency-name: "Microsoft.AspNetCore.Routing" - - # DuckTyping libraries are kept at the lowest supported version for compatibility on netstandard2.0 + # these libraries are kept at the lowest supported version for compatibility on netstandard2.0 - dependency-name: "System.Reflection.Emit" - dependency-name: "System.Reflection.Emit.Lightweight" - ### End Datadog.Trace.csproj ignored dependencies - open-pull-requests-limit: 0 # disable version updates + schedule: + day: sunday + interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f5cde9978..2b5809b0e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,3 +42,31 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }} - name: Run './build.cmd Workflow' run: ./build.cmd Workflow + ubuntu-latest: + name: ubuntu-latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Cache .nuke/temp, ~/.nuget/packages + uses: actions/cache@v2 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }} + - name: Run './build.cmd Workflow' + run: ./build.cmd Workflow + macOS-latest: + name: macOS-latest + runs-on: macOS-latest + steps: + - uses: actions/checkout@v1 + - name: Cache .nuke/temp, ~/.nuget/packages + uses: actions/cache@v2 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }} + - name: Run './build.cmd Workflow' + run: ./build.cmd Workflow diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml deleted file mode 100644 index b4a4d015b4..0000000000 --- a/.github/workflows/workflow.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: workflow -on: - push: - branches: [ poc-otel-sdk ] - tags: - - 'v*.*.*' - pull_request: - workflow_dispatch: -jobs: - ci: - strategy: - matrix: - os: [ windows-2019, ubuntu-20.04, macos-10.15 ] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: microsoft/setup-msbuild@v1.0.2 - if: ${{ runner.os == 'Windows' }} - - run: brew install make - if: ${{ runner.os == 'macOS' }} - - name: Build Managed and Native - env: - buildConfiguration: Release - shell: bash - run: ./build_poc.sh diff --git a/README.md b/README.md index 5beb3339cb..d776e24534 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ sudo chmod a+rwx /var/log/opentelemetry/dotnet ### Usage +> Make sure to run `dotnet nuke Clean BuildTracer` before running the PoC smoke test. + For .NET Core 3.1 run: ```sh @@ -93,6 +95,7 @@ sampleAppTargetFramework=net46 ./poc.sh ``` To instrument the .NET BindingRedirect sample application run: + ```sh - sampleAppTargetFramework=net472 sampleApp=BindingRedirect ./poc.sh +sampleAppTargetFramework=net472 sampleApp=BindingRedirect ./poc.sh ``` diff --git a/build.cmd b/build.cmd old mode 100644 new mode 100755 diff --git a/build.ps1 b/build.ps1 old mode 100644 new mode 100755 diff --git a/build/nuke/Build.Steps.cs b/build/nuke/Build.Steps.cs index cce8d3b6aa..4fa45e5f17 100644 --- a/build/nuke/Build.Steps.cs +++ b/build/nuke/Build.Steps.cs @@ -39,7 +39,6 @@ partial class Build readonly IEnumerable TargetFrameworks = new[] { - TargetFramework.NET452, TargetFramework.NET461, TargetFramework.NETSTANDARD2_0, TargetFramework.NETCOREAPP3_1, diff --git a/build/nuke/Build.cs b/build/nuke/Build.cs index f9263e4867..8a30ccc23b 100644 --- a/build/nuke/Build.cs +++ b/build/nuke/Build.cs @@ -10,6 +10,8 @@ [GitHubActions("ci", GitHubActionsImage.WindowsLatest, + GitHubActionsImage.UbuntuLatest, + GitHubActionsImage.MacOsLatest, AutoGenerate = true, OnPushBranches = new[] { "main", "refs/tags/*" }, OnPushExcludePaths = new[] { "docs/*" }, @@ -64,7 +66,7 @@ void DeleteReparsePoints(string path) Target Workflow => _ => _ .Description("GitHub workflow entry point") - .After(Clean) + .DependsOn(Clean) .DependsOn(BuildTracer) .DependsOn(NativeTests); diff --git a/build/nuke/TargetFramework.cs b/build/nuke/TargetFramework.cs index 8a4a955f64..17605c7841 100644 --- a/build/nuke/TargetFramework.cs +++ b/build/nuke/TargetFramework.cs @@ -9,11 +9,9 @@ [TypeConverter(typeof(TargetFrameworkTypeConverter))] public class TargetFramework : Enumeration { - public static TargetFramework NET452 = new TargetFramework { Value = "net452" }; public static TargetFramework NET461 = new TargetFramework { Value = "net461" }; public static TargetFramework NETSTANDARD2_0 = new TargetFramework { Value = "netstandard2.0" }; public static TargetFramework NETCOREAPP2_1 = new TargetFramework { Value = "netcoreapp2.1" }; - public static TargetFramework NETCOREAPP3_0 = new TargetFramework { Value = "netcoreapp3.0" }; public static TargetFramework NETCOREAPP3_1 = new TargetFramework { Value = "netcoreapp3.1" }; public static TargetFramework NET5_0 = new TargetFramework { Value = "net5.0" }; diff --git a/build_poc.sh b/build_poc.sh deleted file mode 100755 index 658c6da51a..0000000000 --- a/build_poc.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -set -euxo pipefail - -uname_os() { - os=$(uname -s | tr '[:upper:]' '[:lower:]') - case "$os" in - cygwin_nt*) echo "windows" ;; - mingw*) echo "windows" ;; - msys_nt*) echo "windows" ;; - *) echo "$os" ;; - esac -} - -native_sufix() { - os=$(uname_os) - case "$os" in - windows*) echo "dll" ;; - linux*) echo "so" ;; - darwin*) echo "dylib" ;; - *) echo "OS: ${os} is not supported" ; exit 1 ;; - esac -} - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -cd $DIR - -BUILD_TYPE=${buildConfiguration:-Debug} -OUTDIR="$( pwd )/src/Datadog.Trace.ClrProfiler.Native/bin/${BUILD_TYPE}/x64" - -# build Loader -dotnet build -c $BUILD_TYPE src/Datadog.Trace.ClrProfiler.Managed.Loader/Datadog.Trace.ClrProfiler.Managed.Loader.csproj - -# build Native -os=$(uname_os) -case "$os" in - windows*) - SDK_TARGET_FRAMEWORKS="net452 net461 netstandard2.0 netcoreapp3.1" - nuget restore "src\Datadog.Trace.ClrProfiler.Native\Datadog.Trace.ClrProfiler.Native.vcxproj" -SolutionDirectory . - msbuild.exe Datadog.Trace.proj -t:BuildCpp -p:Configuration=${BUILD_TYPE} -p:Platform=x64 - ;; - - *) - SDK_TARGET_FRAMEWORKS="netstandard2.0 netcoreapp3.1" - cd src/Datadog.Trace.ClrProfiler.Native - - mkdir -p build - (cd build && cmake ../ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} && make) - - cd $DIR - SUFIX=$(native_sufix) - mkdir -p ${OUTDIR} - cp -f src/Datadog.Trace.ClrProfiler.Native/build/bin/Datadog.Trace.ClrProfiler.Native.${SUFIX} ${OUTDIR}/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.${SUFIX} -esac - -# build Managed -cd $DIR - -for framework in ${SDK_TARGET_FRAMEWORKS} ; do - mkdir -p "$OUTDIR/$framework" - dotnet publish -f $framework -c ${BUILD_TYPE} src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.csproj -o "$OUTDIR/$framework" - dotnet publish -f $framework -c ${BUILD_TYPE} samples/Vendor.Distro/Vendor.Distro.csproj -o "$OUTDIR/$framework" -done diff --git a/dev/envvars.sh b/dev/envvars.sh index dc2996ed26..0aa3a74284 100755 --- a/dev/envvars.sh +++ b/dev/envvars.sh @@ -35,20 +35,19 @@ SUFIX=$(native_sufix) # Enable .NET Framework Profiling API export COR_ENABLE_PROFILING="1" export COR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}" -export COR_PROFILER_PATH="${CURDIR}/src/Datadog.Trace.ClrProfiler.Native/bin/Debug/x64/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.${SUFIX}" +export COR_PROFILER_PATH="${CURDIR}/bin/tracer-home/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.${SUFIX}" # Enable .NET Core Profiling API export CORECLR_ENABLE_PROFILING="1" export CORECLR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}" -export CORECLR_PROFILER_PATH="${CURDIR}/src/Datadog.Trace.ClrProfiler.Native/bin/Debug/x64/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.${SUFIX}" +export CORECLR_PROFILER_PATH="${CURDIR}/bin/tracer-home/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.${SUFIX}" # Configure OpenTelemetry Tracer -export OTEL_DOTNET_TRACER_HOME="${CURDIR}/src/Datadog.Trace.ClrProfiler.Native/bin/Debug/x64" -export OTEL_INTEGRATIONS="${CURDIR}/integrations.json" +export OTEL_DOTNET_TRACER_HOME="${CURDIR}/bin/tracer-home" +export OTEL_INTEGRATIONS="${CURDIR}/bin/tracer-home/integrations.json" export OTEL_VERSION="1.0.0" -export OTEL_EXPORTER_ZIPKIN_ENDPOINT="http://localhost:9411/api/v2/spans" export OTEL_TRACE_DEBUG="1" -export OTEL_EXPORTER="zipkin" +export OTEL_EXPORTER="jaeger" export OTEL_DUMP_ILREWRITE_ENABLED="0" export OTEL_CLR_ENABLE_INLINING="1" export OTEL_PROFILER_EXCLUDE_PROCESSES="dotnet.exe,dotnet" diff --git a/docs/USAGE.md b/docs/USAGE.md index 5943f0ded9..e19fddfa2c 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -58,7 +58,9 @@ Use these environment variables to configure the tracing library: | `OTEL_MAX_LOGFILE_SIZE` | The maximum size for tracer log files, in bytes. | `10 MB` | | `OTEL_TRACE_LOG_PATH` | The path of the profiler log file. | Linux: `/var/log/OTEL/dotnet/dotnet-profiler.log`
Windows: `%ProgramData%"\OTEL .NET Tracing\logs\dotnet-profiler.log` | | `OTEL_DIAGNOSTIC_SOURCE_ENABLED` | Enable to generate troubleshooting logs with the `System.Diagnostics.DiagnosticSource` class. | `true` | -| `OTEL_DOTNET_TRACER_DISABLED_INSTRUMENTATIONS` | The instrumentations you want to disable, if any, separated by a comma. These are the supported integrations: `AspNet`, `HttpClient`, `SqlClient`, `MongoDb` | | +| `OTEL_INTEGRATIONS` | The file path of IL-rewrite instrumentations JSON configuration file. | `%ProfilerDirectory%/integrations.json` | +| `OTEL_DOTNET_TRACER_INSTRUMENTATIONS` | The instrumentations you want to enable, separated by a comma. Supported values: `AspNet`, `HttpClient`, `SqlClient`, `MongoDb`. | | +| `OTEL_DOTNET_TRACER_DISABLED_INSTRUMENTATIONS` | The instrumentations set via `OTEL_DOTNET_TRACER_INSTRUMENTATIONS` value and `OTEL_INTEGRATIONS` configuration file you want to disable, separated by a comma. | | | `OTEL_CONVENTION` | Sets the semantic and trace id conventions for the tracer. Available values are: `Datadog` (64bit trace id), `OpenTelemetry` (128 bit trace id). | `Datadog` | | `OTEL_PROPAGATORS` | Comma separated list of the propagators for the tracer. Available propagators are: `Datadog`, `B3`, `W3C`. The Tracer will try to execute extraction in the given order. | `Datadog` | | `OTEL_TRACE_DOMAIN_NEUTRAL_INSTRUMENTATION` | Sets whether to intercept method calls when the caller method is inside a domain-neutral assembly. This is recommended when instrumenting IIS applications. | `false` | @@ -117,7 +119,7 @@ A plugin must be a non-static, non-abstract class which has a default constructo public OpenTelemetry.Trace.TracerProviderBuilder ConfigureTracerProvider(OpenTelemetry.Trace.TracerProviderBuilder builder) ``` -The plugin must use the same version of the `OpenTelemetry` as the OpenTelemetry .NET AutoInstrumentation. Current version is `1.1.0-beta2`. +The plugin must use the same version of the `OpenTelemetry` as the OpenTelemetry .NET AutoInstrumentation. Current version is `1.2.0-alpha1`. ## Setup @@ -255,18 +257,18 @@ Enable instrumentation for a specific user: ## Configure custom instrumentation -The instrumented application has to include same version of the `System.Diagnostics.DiagnosticSource` as the SDK. Current version is `5.0.1`. +The instrumented application has to include same version of the `System.Diagnostics.DiagnosticSource` as the SDK. Current version is `6.0.0-preview.6.21352.12`. Include package reference directly into `.csproj`: ```xml - + ``` ... or use Package Manager Console to install package: ```powershell -Install-Package System.Diagnostics.DiagnosticSource -Version 5.0.1 -ProjectName MyProjectName +Install-Package System.Diagnostics.DiagnosticSource -Version 6.0.0-preview.6.21352.12 -ProjectName MyProjectName ``` For adding manual instrumentation the variable `OTEL_DOTNET_TRACER_LOAD_AT_STARTUP` should be set to `false` and the tracer should be initialized by the application itself. Here is an example of creating the tracer: @@ -316,8 +318,15 @@ These are ";" delimited lists that control the inclusion/exclusion of processes. ### No proper relatioship between spans -On .NET Framework strong name signing can force multiple versions of the same assembly being loaded on the same process. This causes a separate hierarchy of Activity objects. If you are referencing packages in your application that use different version of the `System.Diagnostics.DiagnosticSource` than the `OpenTelemetry.Api` used by autoinstrumentation (`5.0.1`) you have to explicitly reference the `System.Diagnostics.DiagnosticSource` package in the correct version in your application (see [custom instrumentation section](#configure-custom-instrumentation)). This will cause automatic binding redirection to occur resolving the issue. If automatic binding redirection is [disabled](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection) you can also manually add binding redirection to [the `App.config` file](../samples/BindingRedirect/App.config). -``` +On .NET Framework strong name signing can force multiple versions of the same assembly being loaded on the same process. +This causes a separate hierarchy of Activity objects. If you are referencing packages in your application that use +different version of the `System.Diagnostics.DiagnosticSource` than the `OpenTelemetry.Api` used by autoinstrumentation +(`6.0.0-preview.6.21352.12`) you have to explicitly reference the `System.Diagnostics.DiagnosticSource` package in the correct version +in your application (see [custom instrumentation section](#configure-custom-instrumentation)). +This will cause automatic binding redirection to occur resolving the issue. + +If automatic binding redirection is [disabled](https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection) +you can also manually add binding redirection to [the `App.config` file](../samples/BindingRedirect/App.config). ### Investigating other issues diff --git a/poc.sh b/poc.sh index 3824fa0bad..484acb4b44 100755 --- a/poc.sh +++ b/poc.sh @@ -16,8 +16,11 @@ function finish { } trap finish EXIT -# build managed and native code -./build_poc.sh +# copy profiler to good location +cp bin/tracer-home/win-x64/OpenTelemetry.AutoInstrumentation.ClrProfiler.Native.dll bin/tracer-home/ + +# build plugin for HTTP server app +dotnet publish -f $aspNetAppTargetFramework samples/Vendor.Distro/Vendor.Distro.csproj -o bin/tracer-home/$aspNetAppTargetFramework # start mongodb docker run -d --rm --name mongo \ @@ -44,14 +47,12 @@ docker run -d --rm --name jaeger \ # instrument and run HTTP server app in background export OTEL_DOTNET_TRACER_INSTRUMENTATION_PLUGINS="Samples.AspNetCoreMvc.OtelSdkPlugin, Samples.AspNetCoreMvc31, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null:Vendor.Distro.Plugin, Vendor.Distro, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null" -./dev/instrument.sh ASPNETCORE_URLS="http://127.0.0.1:8080/" OTEL_SERVICE="aspnet-server" dotnet run --no-launch-profile -f $aspNetAppTargetFramework -p ./samples/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj & +./dev/instrument.sh OTEL_DOTNET_TRACER_INSTRUMENTATIONS="AspNet,SqlClient,MongoDb" OTEL_SERVICE="aspnet-server" ASPNETCORE_URLS="http://127.0.0.1:8080/" dotnet run --no-launch-profile -f $aspNetAppTargetFramework -p ./samples/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj & unset OTEL_DOTNET_TRACER_INSTRUMENTATION_PLUGINS ./dev/wait-local-port.sh 8080 # instrument and run HTTP client app -export OTEL_DOTNET_TRACER_INSTRUMENTATION_PLUGINS="Vendor.Distro.Plugin, Vendor.Distro, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null" -time ./dev/instrument.sh OTEL_SERVICE="http-client" dotnet run --no-launch-profile -f $sampleAppTargetFramework -p ./samples/${sampleApp}/${sampleApp}.csproj -unset OTEL_DOTNET_TRACER_INSTRUMENTATION_PLUGINS +time ./dev/instrument.sh OTEL_DOTNET_TRACER_INSTRUMENTATIONS="HttpClient" OTEL_SERVICE="http-client" dotnet run --no-launch-profile -f $sampleAppTargetFramework -p ./samples/${sampleApp}/${sampleApp}.csproj # verify if it works read -p "Check traces under: http://localhost:16686/search. Press enter to continue" diff --git a/samples/ConsoleApp.SelfBootstrap/ConsoleApp.SelfBootstrap.csproj b/samples/ConsoleApp.SelfBootstrap/ConsoleApp.SelfBootstrap.csproj index c242cc8e49..76b36e891c 100644 --- a/samples/ConsoleApp.SelfBootstrap/ConsoleApp.SelfBootstrap.csproj +++ b/samples/ConsoleApp.SelfBootstrap/ConsoleApp.SelfBootstrap.csproj @@ -2,7 +2,7 @@ Exe - net452;net46;net461;netcoreapp2.1;netcoreapp3.1;net5.0 + net461;netcoreapp2.1;netcoreapp3.1;net5.0 @@ -10,15 +10,16 @@ - - - - - - - - - + + + + + + + + + + diff --git a/samples/ConsoleApp/ConsoleApp.csproj b/samples/ConsoleApp/ConsoleApp.csproj index 4350620a7f..eeaf2f9d42 100644 --- a/samples/ConsoleApp/ConsoleApp.csproj +++ b/samples/ConsoleApp/ConsoleApp.csproj @@ -2,7 +2,7 @@ Exe - net452;net46;net461;netcoreapp2.1;netcoreapp3.1;net5.0 + net461;netcoreapp2.1;netcoreapp3.1;net5.0 9.0 @@ -11,7 +11,7 @@ - + diff --git a/samples/OpenTracingLibrary/OpenTracingLibrary.csproj b/samples/OpenTracingLibrary/OpenTracingLibrary.csproj index 5efb5bf0d4..394da9dc91 100644 --- a/samples/OpenTracingLibrary/OpenTracingLibrary.csproj +++ b/samples/OpenTracingLibrary/OpenTracingLibrary.csproj @@ -1,7 +1,7 @@ - net452;net462;netstandard2.0 + net462;netstandard2.0 diff --git a/samples/Samples.AspNetCoreMvc21/Samples.AspNetCoreMvc21.csproj b/samples/Samples.AspNetCoreMvc21/Samples.AspNetCoreMvc21.csproj index 8b07c68feb..aa6b8cfc18 100644 --- a/samples/Samples.AspNetCoreMvc21/Samples.AspNetCoreMvc21.csproj +++ b/samples/Samples.AspNetCoreMvc21/Samples.AspNetCoreMvc21.csproj @@ -16,9 +16,10 @@ - - + + + diff --git a/samples/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj b/samples/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj index 5286de6ec7..86f133b7ff 100644 --- a/samples/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj +++ b/samples/Samples.AspNetCoreMvc31/Samples.AspNetCoreMvc31.csproj @@ -7,10 +7,10 @@ - - + + - + diff --git a/samples/Vendor.Distro/Vendor.Distro.csproj b/samples/Vendor.Distro/Vendor.Distro.csproj index 212071152e..ea75c2f13f 100644 --- a/samples/Vendor.Distro/Vendor.Distro.csproj +++ b/samples/Vendor.Distro/Vendor.Distro.csproj @@ -1,7 +1,7 @@  - net452;net461;netstandard2.0;netcoreapp3.1 + net461;netstandard2.0;netcoreapp3.1;net5.0 0.0.1 diff --git a/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs b/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs index 304cb1916d..77c59b56dd 100644 --- a/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs +++ b/src/Datadog.Trace.ClrProfiler.Managed.Loader/Startup.NetFramework.cs @@ -13,18 +13,8 @@ public partial class Startup { private static string ResolveManagedProfilerDirectory() { - // We currently build two assemblies targeting .NET Framework. - // If we're running on the .NET Framework, load the highest-compatible assembly - string corlibFileVersionString = ((AssemblyFileVersionAttribute)typeof(object).Assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute))).Version; - string corlib461FileVersionString = "4.6.1055.0"; - - // This will throw an exception if the version number does not match the expected 2-4 part version number of non-negative int32 numbers, - // but mscorlib should be versioned correctly - var corlibVersion = new Version(corlibFileVersionString); - var corlib461Version = new Version(corlib461FileVersionString); - var tracerFrameworkDirectory = corlibVersion < corlib461Version ? "net452" : "net461"; - var tracerHomeDirectory = ReadEnvironmentVariable("OTEL_DOTNET_TRACER_HOME") ?? string.Empty; + var tracerFrameworkDirectory = "net461"; return Path.Combine(tracerHomeDirectory, tracerFrameworkDirectory); } diff --git a/src/Datadog.Trace.ClrProfiler.Native/Datadog.Trace.ClrProfiler.Native.vcxproj b/src/Datadog.Trace.ClrProfiler.Native/Datadog.Trace.ClrProfiler.Native.vcxproj index e7b8f604cc..d72affa910 100644 --- a/src/Datadog.Trace.ClrProfiler.Native/Datadog.Trace.ClrProfiler.Native.vcxproj +++ b/src/Datadog.Trace.ClrProfiler.Native/Datadog.Trace.ClrProfiler.Native.vcxproj @@ -62,7 +62,7 @@ - + @@ -233,6 +233,6 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/Datadog.Trace.ClrProfiler.Native/packages.config b/src/Datadog.Trace.ClrProfiler.Native/packages.config index 5452db3bab..b4e1b82466 100644 --- a/src/Datadog.Trace.ClrProfiler.Native/packages.config +++ b/src/Datadog.Trace.ClrProfiler.Native/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs index adf58dfc42..57e76f6b51 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/ConfigurationKeys.cs @@ -51,19 +51,14 @@ public class ConfigurationKeys public const string ZipkinEndpoint = "OTEL_EXPORTER_ZIPKIN_ENDPOINT"; /// - /// Configuration key for hostname for the Jaeger agent. - /// - public const string JaegerExporterAgentHost = "OTEL_EXPORTER_JAEGER_AGENT_HOST"; - - /// - /// Configuration key for port for the Jaeger agent. + /// Configuration key for whether the console exporter is enabled. /// - public const string JaegerExporterAgentPort = "OTEL_EXPORTER_JAEGER_AGENT_PORT"; + public const string ConsoleExporterEnabled = "OTEL_DOTNET_TRACER_CONSOLE_EXPORTER_ENABLED"; /// - /// Configuration key for whether the console exporter is enabled. + /// Configuration key for comma separated list of enabled instrumentations. /// - public const string ConsoleExporterEnabled = "OTEL_DOTNET_TRACER_CONSOLE_EXPORTER_ENABLED"; + public const string Instrumentations = "OTEL_DOTNET_TRACER_INSTRUMENTATIONS"; /// /// Configuration key for comma separated list of disabled instrumentations. diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs index 77bc551703..edd9aab056 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/EnvironmentConfigurationHelper.cs @@ -44,7 +44,7 @@ public static TracerProviderBuilder UseEnvironmentVariables(this TracerProviderB public static TracerProviderBuilder AddSdkAspNetInstrumentation(this TracerProviderBuilder builder) { -#if NET452 || NET461 +#if NET461 return builder.AddAspNetInstrumentation(); #elif NETCOREAPP3_1_OR_GREATER return builder.AddAspNetCoreInstrumentation(); @@ -68,19 +68,10 @@ private static TracerProviderBuilder SetExporter(this TracerProviderBuilder buil options.Endpoint = settings.ZipkinEndpoint; options.ExportProcessorType = ExportProcessorType.Simple; // for PoC }); - break; case "jaeger": -#if NET452 - throw new NotSupportedException(); -#else - var agentHost = settings.JaegerExporterAgentHost; - var agentPort = settings.JaegerExporterAgentPort; - builder.AddJaegerExporter(options => { - options.AgentHost = agentHost; - options.AgentPort = agentPort; options.ExportProcessorType = ExportProcessorType.Simple; // for PoC }); break; @@ -88,7 +79,6 @@ private static TracerProviderBuilder SetExporter(this TracerProviderBuilder buil break; default: throw new ArgumentOutOfRangeException("The exporter name is not recognised"); -#endif } return builder; diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/Settings.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/Settings.cs index fa7c7f2a22..182d5d90d4 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/Settings.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Configuration/Settings.cs @@ -33,22 +33,19 @@ private Settings(IConfigurationSource source) ZipkinEndpoint = new Uri(source.GetString(ConfigurationKeys.ZipkinEndpoint) ?? "http://localhost:8126"); - JaegerExporterAgentHost = source.GetString(ConfigurationKeys.JaegerExporterAgentHost) ?? "localhost"; - JaegerExporterAgentPort = source.GetInt32(ConfigurationKeys.JaegerExporterAgentPort) ?? 6831; - LoadTracerAtStartup = source.GetBool(ConfigurationKeys.LoadTracerAtStartup) ?? true; ConsoleExporterEnabled = source.GetBool(ConfigurationKeys.ConsoleExporterEnabled) ?? true; - EnabledInstrumentations = Enum.GetValues(typeof(Instrumentation)).Cast().ToList(); - var disabledInstrumentations = source.GetString(ConfigurationKeys.DisabledInstrumentations); - if (disabledInstrumentations != null) + var instrumentations = new Dictionary(); + var enabledInstrumentations = source.GetString(ConfigurationKeys.Instrumentations); + if (enabledInstrumentations != null) { - foreach (var instrumentation in disabledInstrumentations.Split(separator: ',')) + foreach (var instrumentation in enabledInstrumentations.Split(separator: ',')) { if (Enum.TryParse(instrumentation, out Instrumentation parsedType)) { - EnabledInstrumentations.Remove(parsedType); + instrumentations[instrumentation] = parsedType; } else { @@ -57,6 +54,17 @@ private Settings(IConfigurationSource source) } } + var disabledInstrumentations = source.GetString(ConfigurationKeys.DisabledInstrumentations); + if (disabledInstrumentations != null) + { + foreach (var instrumentation in disabledInstrumentations.Split(separator: ',')) + { + instrumentations.Remove(instrumentation); + } + } + + EnabledInstrumentations = instrumentations.Values.ToList(); + var providerPlugins = source.GetString(ConfigurationKeys.ProviderPlugins); if (providerPlugins != null) { diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.Utilities.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.Utilities.cs index 046b4e206c..80a1e35aba 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.Utilities.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.Utilities.cs @@ -27,13 +27,6 @@ private static void EnsureArguments(Type proxyType, object instance) { DuckTypeTargetObjectInstanceIsNull.Throw(); } - -#if NET452 - if (!proxyType.IsVisible) - { - DuckTypeTypeIsNotPublicException.Throw(proxyType, nameof(proxyType)); - } -#endif } /// @@ -84,9 +77,6 @@ private static bool NeedsDuckChaining(Type targetType, Type proxyType) /// true for direct method; otherwise, false. private static bool UseDirectAccessTo(ModuleBuilder builder, Type targetType) { -#if NET452 - return targetType.IsVisible; -#else if (builder == null) { return targetType.IsVisible; @@ -94,7 +84,6 @@ private static bool UseDirectAccessTo(ModuleBuilder builder, Type targetType) EnsureTypeVisibility(builder, targetType); return true; -#endif } /// diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.cs index 1e3bd52e30..e78140cb60 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/DuckTyping/DuckType.cs @@ -730,12 +730,6 @@ public static bool CanCreate(object instance) private static CreateTypeResult GetProxySlow(Type targetType) { Type proxyTypeDefinition = typeof(T); -#if NET452 - if (!proxyTypeDefinition.IsValueType && !UseDirectAccessTo(proxyTypeDefinition)) - { - DuckTypeTypeIsNotPublicException.Throw(proxyTypeDefinition, nameof(proxyTypeDefinition)); - } -#endif return GetOrCreateProxyType(proxyTypeDefinition, targetType); } } diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.csproj b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.csproj index 5f2690b4ce..315225969f 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.csproj +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.csproj @@ -1,22 +1,22 @@  - net452;net461;netstandard2.0;netcoreapp3.1 + net461;netstandard2.0;netcoreapp3.1 0.0.1 - - - - - - - - - - - + + + + + + + + + + + diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/ArrayHelper.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/ArrayHelper.cs index 17debcf9bd..cef0889dac 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/ArrayHelper.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/ArrayHelper.cs @@ -6,11 +6,7 @@ internal static class ArrayHelper { public static T[] Empty() { -#if NET452 - return EmptyArray.Value; -#else return Array.Empty(); -#endif } public static T[] Concat(this T[] array, params T[] newElements) @@ -22,12 +18,5 @@ public static T[] Concat(this T[] array, params T[] newElements) return destination; } - -#if NET452 - private static class EmptyArray - { - internal static readonly T[] Value = new T[0]; - } -#endif } } diff --git a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/PointerHelpers.cs b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/PointerHelpers.cs index 2a59f5adaf..3001ce20f1 100644 --- a/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/PointerHelpers.cs +++ b/src/OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed/Util/PointerHelpers.cs @@ -8,13 +8,7 @@ internal static class PointerHelpers public static Guid GetGuidFromNativePointer(long nativePointer) { var ptr = new IntPtr(nativePointer); -#if NET452 - // deprecated - var moduleVersionId = (Guid)Marshal.PtrToStructure(ptr, typeof(Guid)); -#else - // added in net451 var moduleVersionId = Marshal.PtrToStructure(ptr); -#endif return moduleVersionId; } } diff --git a/test/Datadog.Trace.ClrProfiler.Native.Tests/Datadog.Trace.ClrProfiler.Native.Tests.vcxproj b/test/Datadog.Trace.ClrProfiler.Native.Tests/Datadog.Trace.ClrProfiler.Native.Tests.vcxproj index 2a5153d24b..8cfa281908 100644 --- a/test/Datadog.Trace.ClrProfiler.Native.Tests/Datadog.Trace.ClrProfiler.Native.Tests.vcxproj +++ b/test/Datadog.Trace.ClrProfiler.Native.Tests/Datadog.Trace.ClrProfiler.Native.Tests.vcxproj @@ -99,8 +99,8 @@ - + @@ -193,7 +193,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/test/Datadog.Trace.ClrProfiler.Native.Tests/packages.config b/test/Datadog.Trace.ClrProfiler.Native.Tests/packages.config index d974a133db..95411c14da 100644 --- a/test/Datadog.Trace.ClrProfiler.Native.Tests/packages.config +++ b/test/Datadog.Trace.ClrProfiler.Native.Tests/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file