Load Datadog.Trace.ClrProfiler.Managed via the AppDomain.AssemblyResolve event#505
Merged
Merged
Conversation
…tandard2.0. The net45 target framework will be used for all .NET Framework applications and netstandard2.0 for all .NET Core applications.
…ectly on net452 and net461.
…lies to the build output for netstandard2.0. This allows apps using the netstandard2.0 profiler to run.
…s are in one file.
…library based on the mscorlib assembly at runtime.
- Make Datadog.Trace.ClrProfiler.ManagedLoader target netcoreapp2.0 (instead of netstandard2.0) to use AssemblyLoadContext class - Add implementation class for AssemblyLoadContext - Always load our main Datadog assemblies into the LoadFrom context but on .NET Core, load the dependencies into a separate Assembly Load Context
…p target of Datadog.Trace.proj and explicitly build the project in previous CI steps.
…o using the profiler from the profiler directory.
…adog.Trace assemblies to load.
…bsequent attempts skip early.
| "CORECLR_PROFILER_PATH": "$(ProjectDir)$(OutputPath)profiler-lib\\Datadog.Trace.ClrProfiler.Native.dll", | ||
|
|
||
| "DD_DOTNET_TRACER_HOME": "$(ProjectDir)$(OutputPath)profiler-lib", | ||
| "DD_INTEGRATIONS": "$(ProjectDir)$(OutputPath)profiler-lib\\integrations.json" |
Member
There was a problem hiding this comment.
Should we drop DD_INTEGRATIONS and figure it out from DD_DOTNET_TRACER_HOME instead? (Can be separate PR)
Contributor
Author
There was a problem hiding this comment.
Is there anywhere where we might need the flexibility of an integrations file outside of the profiler directory? Perhaps we could default to the DD_DOTNET_TRACER_HOME directory and use DD_INTEGRATIONS as a sort of override?
Member
There was a problem hiding this comment.
default to the
DD_DOTNET_TRACER_HOMEdirectory and useDD_INTEGRATIONSas a sort of override
I like this idea. The latter also lets us define multiple json files. We should probably also rename that to DD_DOTNET_INTEGRATIONS at some point.
Let's leave as-is for this PR and come back to that later.
Add DD_DOTNET_TRACER_HOME to Windows MSI.
This reverts commit 7a2a2ce.
ba8fdbd to
74ef326
Compare
lucaspimentel
approved these changes
Sep 17, 2019
macrogreg
pushed a commit
that referenced
this pull request
Aug 20, 2021
…lve event (#505) Product changes: - In `Datadog.Trace.ClrProfiler.Managed.Loader` add the `AppDomain.AssemblyResolve` event handler to load managed profiler dependencies from disk where the profiler is installed. This would remove the need to install files into the GAC or add the `Datadog.Trace.ClrProfiler.Managed` NuGet package to receive auto-instrumentation. - Stop adding assembly references to the managed profiler code in `ModuleLoadFinished` and instead do that operation in `JITCompilationStarted`. Because of this delayed reference, the runtime will not be able to resolve the assembly reference automatically (perhaps avoiding the SecurityGrant exceptions we have seen in the past!) and will rely on the newly implemented `AppDomain.AssemblyResolve` event to find the managed profiler code. - Build `Datadog.Trace.ClrProfiler.Managed.Loader` for `netcoreapp2.0` and `net45` because reading environment variables (to obtain profiler file path) is only supported on `netstandard1.3` and higher. Build changes: - Combine common settings in `Directory.Build.props` for reproductions, reproduction-dependencies, and samples into `./Test.Common.props` - For Windows-ready xUnit integration tests, add the `RunOnWindows=True` trait - Produce managed profiler assets by running `dotnet publish Datadog.Trace.ClrProfiler.Managed` for each target framework - Stop building `Datadog.Trace.ClrProfiler.Managed.Loader.csproj` inside `Datadog.Trace.proj`'s `BuildCpp` target and instead build it separately whenever we build `Datadog.Trace.ClrProfiler.Native`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Product changes:
Datadog.Trace.ClrProfiler.Managed.Loaderadd theAppDomain.AssemblyResolveevent handler to load managed profiler dependencies from disk where the profiler is installed. This would remove the need to install files into the GAC or add theDatadog.Trace.ClrProfiler.ManagedNuGet package to receive auto-instrumentation.ModuleLoadFinishedand instead do that operation inJITCompilationStarted. Because of this delayed reference, the runtime will not be able to resolve the assembly reference automatically (perhaps avoiding the SecurityGrant exceptions we have seen in the past!) and will rely on the newly implementedAppDomain.AssemblyResolveevent to find the managed profiler code.Datadog.Trace.ClrProfiler.Managed.Loaderfornetcoreapp2.0andnet45because reading environment variables (to obtain profiler file path) is only supported onnetstandard1.3and higher.Build changes:
Directory.Build.propsfor reproductions, reproduction-dependencies, and samples into./Test.Common.propsRunOnWindows=Truetraitdotnet publish Datadog.Trace.ClrProfiler.Managedfor each target frameworkDatadog.Trace.ClrProfiler.Managed.Loader.csprojinsideDatadog.Trace.proj'sBuildCpptarget and instead build it separately whenever we buildDatadog.Trace.ClrProfiler.Native(edit: formatting)