Skip to content

Commit

Permalink
[POC] Add OTEL_DOTNET_TRACER_INSTRUMENTATIONS and bump dependencies (#…
Browse files Browse the repository at this point in the history
…204)

- Require explicit enabling of the SDK integrations via the new OTEL_DOTNET_TRACER_INSTRUMENTATIONS env var
- Update dependencies
- Remove handling of OTEL_EXPORTER_JAEGER_AGENT_HOST and OTEL_EXPORTER_JAEGER_AGENT_PORT env vars
- Drop support for .NET which are no longer supported by the SDK (net452 and net46)
- Little build and CI improvements
  • Loading branch information
pellared authored Jul 29, 2021
1 parent e61cf4b commit bd294b1
Show file tree
Hide file tree
Showing 32 changed files with 143 additions and 313 deletions.
111 changes: 19 additions & 92 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 0 additions & 25 deletions .github/workflows/workflow.yml

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
Empty file modified build.cmd
100644 → 100755
Empty file.
Empty file modified build.ps1
100644 → 100755
Empty file.
1 change: 0 additions & 1 deletion build/nuke/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ partial class Build

readonly IEnumerable<TargetFramework> TargetFrameworks = new[]
{
TargetFramework.NET452,
TargetFramework.NET461,
TargetFramework.NETSTANDARD2_0,
TargetFramework.NETCOREAPP3_1,
Expand Down
4 changes: 3 additions & 1 deletion build/nuke/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

[GitHubActions("ci",
GitHubActionsImage.WindowsLatest,
GitHubActionsImage.UbuntuLatest,
GitHubActionsImage.MacOsLatest,
AutoGenerate = true,
OnPushBranches = new[] { "main", "refs/tags/*" },
OnPushExcludePaths = new[] { "docs/*" },
Expand Down Expand Up @@ -64,7 +66,7 @@ void DeleteReparsePoints(string path)

Target Workflow => _ => _
.Description("GitHub workflow entry point")
.After(Clean)
.DependsOn(Clean)
.DependsOn(BuildTracer)
.DependsOn(NativeTests);

Expand Down
2 changes: 0 additions & 2 deletions build/nuke/TargetFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" };

Expand Down
62 changes: 0 additions & 62 deletions build_poc.sh

This file was deleted.

11 changes: 5 additions & 6 deletions dev/envvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 16 additions & 7 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`<br>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` |
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0-preview.6.21352.12" />
```

... 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:
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit bd294b1

Please sign in to comment.