Skip to content

Commit

Permalink
Update native code (#2280)
Browse files Browse the repository at this point in the history
* Port all of the changes to the native product and native tests

* Pass integrations to the profiler via C# and PInvoke, instead of integrations.json

* Delete integrations.json and remove environment variable OTEL_DOTNET_AUTO_INTEGRATIONS_FILE

* Add ByRef improvements to the CallTarget infrastructure:
- struct CallTargetReturn/CallTargetReturn<T> is now a readonly ref struct
- Pass CallTargetState by ref into EndMethod integration callbacks
- Pass input arguments by ref into BeginMethod integration callbacks

See DataDog/dd-trace-dotnet@f2cbb4b

* Really small changes to CallTarget infrastructure

* Fix build when using C#11

* Run format-native.sh

* Update native headers

* Fix possible null reference exception

* Fix changelog lint error

* Fix yet another native header issue

* Skip the StrongNamedTests for now

* Add the instrumentation type ("Trace|Log|Metric") and the instrumentation name (e.g. "GraphQL") to each instrumentation to allow for enabling and disabling integrations via environment variables

* Fix native format errors

* Fix the StackExchangeRedis integration definitions, which should resolve the integration test issues for the CustomSdkTests case and the StackExchangeRedisTests case

* Drop: Temporary launchSettings.json

* Commit updates to NServiceBus to try and resolve multiple System.Diagnostics.DiagnosticSource dll's getting loaded

* Add DiagnosticSource package reference to fix .NET Frameowrk test applications

* Add test skip for "TestApplication.StrongNamedValidation" spans, and document the GH issue that tracks the follow-up work

* Remove Datadog log prefix

* PR feedback: Update comments in NativeCallTargetDefinition.cs to keep the native call target definitions struct in-sync on the managed and native side

---------
  • Loading branch information
zacharycmontoya authored Apr 14, 2023
1 parent b7da4a0 commit df78d34
Show file tree
Hide file tree
Showing 104 changed files with 3,639 additions and 3,613 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h
### Removed

- Remove support for enabling debugging mode with `OTEL_DOTNET_AUTO_DEBUG`.
- Removed `OTEL_DOTNET_AUTO_INTEGRATIONS_FILE` as a required environment
variable for bytecode instrumentation setup

### Fixed

Expand Down
1 change: 0 additions & 1 deletion OpenTelemetry.AutoInstrumentation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
GlobalSuppressions.cs = GlobalSuppressions.cs
integrations.json = integrations.json
LICENSE = LICENSE
docs\README.md = docs\README.md
stylecop.json = stylecop.json
Expand Down
2 changes: 0 additions & 2 deletions OpenTelemetry.DotNet.Auto.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function Get-Environment-Variables-Table([string]$InstallDir, [string]$OTelServi
$DOTNET_STARTUP_HOOKS = Join-Path $InstallDir "net/OpenTelemetry.AutoInstrumentation.StartupHook.dll"

$OTEL_DOTNET_AUTO_HOME = $InstallDir
$OTEL_DOTNET_AUTO_INTEGRATIONS_FILE = Join-Path $InstallDir "integrations.json"

$vars = @{
# .NET Framework
Expand All @@ -100,7 +99,6 @@ function Get-Environment-Variables-Table([string]$InstallDir, [string]$OTelServi
"DOTNET_STARTUP_HOOKS" = $DOTNET_STARTUP_HOOKS;
# OpenTelemetry
"OTEL_DOTNET_AUTO_HOME" = $OTEL_DOTNET_AUTO_HOME;
"OTEL_DOTNET_AUTO_INTEGRATIONS_FILE" = $OTEL_DOTNET_AUTO_INTEGRATIONS_FILE
}

if (-not [string]::IsNullOrWhiteSpace($OTelServiceName)) {
Expand Down
12 changes: 0 additions & 12 deletions build/Build.NuGet.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ partial class Build
.Description(
"Builds the NuGet packages of the project assuming that any necessary build artifacts were already downloaded.")
.DependsOn(BuildManagedSrcNuGetPackages)
.DependsOn(CopyIntegrationsJsonForNuGetPackage)
.DependsOn(SetupRuntimeNativeFolderForNuGetPackage)
.DependsOn(BuildNuSpecNuGetPackages);

Expand All @@ -40,16 +39,6 @@ partial class Build
}
});

Target CopyIntegrationsJsonForNuGetPackage => _ => _
.Unlisted()
.Executes(() =>
{
var source = RootDirectory / "integrations.json";
var dest = RootDirectory / "nuget" / "OpenTelemetry.AutoInstrumentation" /
"contentFiles" / "any" / "any";
CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite);
});

Target SetupRuntimeNativeFolderForNuGetPackage => _ => _
.Unlisted()
.Description("Setup the \"runtimes/{platform}-{architecture}/native\" folders under \"nuget/OpenTelemetry.AutoInstrumentation.Runtime.Native\".")
Expand Down Expand Up @@ -82,7 +71,6 @@ partial class Build

Target BuildNuSpecNuGetPackages => _ => _
.Description("Build the NuGet packages specified by nuget/**/*.nuspec projects.")
.After(CopyIntegrationsJsonForNuGetPackage)
.After(SetupRuntimeNativeFolderForNuGetPackage)
.Executes(() =>
{
Expand Down
20 changes: 0 additions & 20 deletions build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,6 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x) =>
.DependsOn(PublishNativeProfilerLinux)
.DependsOn(PublishNativeProfilerMacOs);

Target GenerateIntegrationsJson => _ => _
.After(PublishManagedProfiler)
.Executes(() =>
{
var generatorTool = Solution.GetProject(Projects.Tools.IntegrationsJsonGenerator);

DotNetRun(s => s
.SetProjectFile(generatorTool));
});

Target GenerateLibraryVersionFiles => _ => _
.After(PublishManagedProfiler)
.Executes(() =>
Expand All @@ -282,16 +272,6 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x) =>
.SetProjectFile(generatorTool));
});

Target CopyIntegrationsJson => _ => _
.Unlisted()
.After(GenerateIntegrationsJson)
.Executes(() =>
{
var source = RootDirectory / "integrations.json";
var dest = TracerHomeDirectory;
CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite);
});

Target CopyInstrumentScripts => _ => _
.Unlisted()
.After(Clean)
Expand Down
2 changes: 0 additions & 2 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ void DeleteReparsePoints(string path)
.DependsOn(GenerateNetFxAssemblyRedirectionSource)
.DependsOn(CompileNativeSrc)
.DependsOn(PublishNativeProfiler)
.DependsOn(GenerateIntegrationsJson)
.DependsOn(CopyIntegrationsJson)
.DependsOn(CopyInstrumentScripts)
.DependsOn(CopyLegalFiles);

Expand Down
1 change: 0 additions & 1 deletion build/Projects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static class Applications
public static class Tools
{
public const string LibraryVersionsGenerator = "LibraryVersionsGenerator";
public const string IntegrationsJsonGenerator = "IntegrationsJsonGenerator";
public const string GacInstallTool = "GacInstallTool";
}
}
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ When running your application, make sure to:
| `DOTNET_SHARED_STORE` | .NET | `$INSTALL_DIR/store` |
| `DOTNET_STARTUP_HOOKS` | .NET | `$INSTALL_DIR/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll` |
| `OTEL_DOTNET_AUTO_HOME` | All versions | `$INSTALL_DIR` |
| `OTEL_DOTNET_AUTO_INTEGRATIONS_FILE` | All versions | `$INSTALL_DIR/integrations.json` |

> **Note**
> Some settings can be omitted on .NET. For more information, see [config.md](config.md#net-clr-profiler).
Expand Down
3 changes: 0 additions & 3 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ with environment variables taking precedence over `App.config` or `Web.config` f

- `OTEL_DOTNET_AUTO_HOME`
- `OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES`
- `OTEL_DOTNET_AUTO_INTEGRATIONS_FILE`
- `OTEL_DOTNET_AUTO_[TRACES|METRICS|LOGS]_[ENABLED|DISABLED]_INSTRUMENTATIONS`
- `OTEL_DOTNET_AUTO_LOG_DIRECTORY`
- `OTEL_LOG_LEVEL`
Expand Down Expand Up @@ -101,7 +100,6 @@ for example `TRACES`, and `{0}` is the case-sensitive name of the instrumentatio

| Environment variable | Description | Default value | Status |
|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `OTEL_DOTNET_AUTO_INTEGRATIONS_FILE` | List of bytecode instrumentations JSON configuration filepaths, delimited by the platform-specific path separator (`;` on Windows, `:` on Linux and macOS). For example: `%ProfilerDirectory%/integrations.json`. It is required for bytecode instrumentations. | | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED` | Enables all instrumentations. | `true` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED` | Enables all trace instrumentations. Overrides `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED`. | Inherited from the current value of `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_TRACES_{0}_INSTRUMENTATION_ENABLED` | Configuration pattern for enabling a specific trace instrumentation, where `{0}` is the uppercase id of the instrumentation you want to enable. Overrides `OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED`. | Inherited from the current value of `OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
Expand Down Expand Up @@ -388,7 +386,6 @@ CORECLR_PROFILER
CORECLR_PROFILER_PATH
CORECLR_PROFILER_PATH_32
CORECLR_PROFILER_PATH_64
OTEL_DOTNET_AUTO_INTEGRATIONS_FILE
```

## .NET Runtime
Expand Down
1 change: 0 additions & 1 deletion examples/demo/otel-dotnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ DOTNET_ADDITIONAL_DEPS="/otel-dotnet-auto/AdditionalDeps"
DOTNET_SHARED_STORE="/otel-dotnet-auto/store"
DOTNET_STARTUP_HOOKS="/otel-dotnet-auto/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
OTEL_DOTNET_AUTO_HOME="/otel-dotnet-auto"
OTEL_DOTNET_AUTO_INTEGRATIONS_FILE="/otel-dotnet-auto/integrations.json"
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"DOTNET_SHARED_STORE": "$(SolutionDir)bin\\tracer-home\\store",
"DOTNET_STARTUP_HOOKS": "$(SolutionDir)bin\\tracer-home\\net\\OpenTelemetry.AutoInstrumentation.StartupHook.dll",
"OTEL_DOTNET_AUTO_HOME": "$(SolutionDir)bin\\tracer-home",
"OTEL_DOTNET_AUTO_INTEGRATIONS_FILE": "$(SolutionDir)bin\\tracer-home\\integrations.json",
"OTEL_DOTNET_AUTO_PLUGINS": "Examples.AspNetCoreMvc.OtelSdkPlugin, Examples.AspNetCoreMvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"OTEL_SERVICE_NAME": "CLRProfiler.IISExpress",
"OTEL_DOTNET_AUTO_METRICS_ADDITIONAL_SOURCES": "Examples.*"
Expand Down Expand Up @@ -80,7 +79,6 @@
"DOTNET_STARTUP_HOOKS": "$(SolutionDir)bin\\tracer-home\\net\\OpenTelemetry.AutoInstrumentation.StartupHook.dll",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper",
"OTEL_DOTNET_AUTO_HOME": "$(SolutionDir)bin\\tracer-home",
"OTEL_DOTNET_AUTO_INTEGRATIONS_FILE": "$(SolutionDir)bin\\tracer-home\\integrations.json",
"OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED": "true",
"OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED": "true",
"OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED": "true",
Expand Down
3 changes: 0 additions & 3 deletions instrument.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,4 @@ if [ "$ENABLE_PROFILING" = "true" ]; then
else
export CORECLR_PROFILER_PATH="$OTEL_DOTNET_AUTO_HOME/$DOTNET_RUNTIME_ID/OpenTelemetry.AutoInstrumentation.Native.$SUFIX"
fi

# Configure the bytecode instrumentation configuration file
export OTEL_DOTNET_AUTO_INTEGRATIONS_FILE="$OTEL_DOTNET_AUTO_HOME/integrations.json"
fi
Loading

0 comments on commit df78d34

Please sign in to comment.