-
Notifications
You must be signed in to change notification settings - Fork 150
Add fallback logic for DD_INTEGRATIONS and DD_DOTNET_TRACER_HOME #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Opening for review to get automatic CI. Will remove the |
… is set but not DD_DOTNET_TRACER_HOME. No crash, but no instrumentation.
…uild variable. For every test project, copy the managed profiler assets into the profiler directory, to simulate the customer scenario.
…ts. This will help later with this PR. Fix integration_loader_test
…nd wix installer." This reverts commit fe58b6d.
…st that we receive traces.
…we pass DD_DOTNET_TRACER_HOME in CI. Will modify this...
00cfba1 to
28e4412
Compare
…ied by the test case, and edit MissingDotnetTracerHomeEnvTest to remove DD_DOTNET_TRACER_HOME
…nd the managed assemblies on-disk when DD_DOTNET_TRACER_HOME is not set but DD_INTEGRATIONS is still set.
…S) when the CI returns the empty string for DD_DOTNET_TRACER_HOME instead of null.
setup and wix installer.
…k all the tests. They'll pass again when I fix the profiler to fill in the DD_INTEGRATIONS path from DD_DOTNET_TRACER_HOME.
…OME if DD_INTEGRATIONS is undefined.
…ionsFromEnvironment, in various environment variable scenarios.
| </ItemGroup> | ||
|
|
||
| <Target Name="AfterBuildCopyManagedProfiler" AfterTargets="AfterBuild" Condition=" '$(LoadManagedProfilerFromProfilerDirectory)' == 'true'"> | ||
| <Target Name="AfterBuildCopyManagedProfiler" AfterTargets="AfterBuild"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm removing $(LoadManagedProfilerFromProfilerDirectory) because it's not intuitive when to use it. For now, while wasteful, we'll always copy all managed binaries to a sample app's profiler-lib directory.
|
|
||
| <ComponentGroup Id="EnvironmentVariables.Machine" Directory="INSTALLFOLDER"> | ||
| <Component Id="EnvironmentVariablesShared" Guid="{C314A305-9C24-4E46-9ECF-E5EEA703BDEA}" Win64="$(var.Win64)"> | ||
| <CreateFolder/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm removing DD_INTEGRATIONS from our MSI since we can key off DD_DOTNET_TRACER_HOME. If for some reason the user has a different integrations.json file they want to use, they can manually set DD_INTEGRATIONS to prioritize that one.
| "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", | ||
| "CORECLR_PROFILER_PATH": "$(ProjectDir)$(OutputPath)profiler-lib\\Datadog.Trace.ClrProfiler.Native.dll", | ||
|
|
||
| "DD_INTEGRATIONS": "$(ProjectDir)$(OutputPath)profiler-lib\\integrations.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This very simple test program uses DD_INTEGRATIONS and doesn't use DD_DOTNET_TRACER_HOME to simulate a user who has upgraded the profiler without updating the environment variables.
| var tracerHomeDirectory = Environment.GetEnvironmentVariable("DD_DOTNET_TRACER_HOME") ?? string.Empty; | ||
|
|
||
| var tracerHomeDirectory = Environment.GetEnvironmentVariable("DD_DOTNET_TRACER_HOME"); | ||
| if (string.IsNullOrWhiteSpace(tracerHomeDirectory)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NET Core: Fallback to DD_INTEGRATIONS if DD_DOTNET_TRACER_HOME was not set.
|
|
||
| var tracerHomeDirectory = Environment.GetEnvironmentVariable("DD_DOTNET_TRACER_HOME") ?? string.Empty; | ||
| var tracerHomeDirectory = Environment.GetEnvironmentVariable("DD_DOTNET_TRACER_HOME"); | ||
| if (string.IsNullOrWhiteSpace(tracerHomeDirectory)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NET Framework: Fallback to DD_INTEGRATIONS if DD_DOTNET_TRACER_HOME was not set.
| auto profiler_home_path = | ||
| GetEnvironmentValue(environment::profiler_home_path); | ||
|
|
||
| if (!profiler_home_path.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple fallback in the profiler: if DD_INTEGRATIONS was not set (as a result, it's the empty string), try DD_DOTNET_TRACER_HOME and if it is not empty, create an integrations.json path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We duplicate this logic in integration_loader.cpp just so we can raise an immediate error immediately here if the environment variables don't look right. Also, for testing purposes, it's much easier to do all of the environment variable processing again in LoadIntegrationsFromEnvironment so we can unit test it.
| GetEnvironmentValue(environment::profiler_home_path); | ||
|
|
||
| if (!profiler_home_path.empty()) { | ||
| const auto fallback_integration_path = std::filesystem::path(profiler_home_path) / "integrations.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use std::filesystem unless we update to a newer build system on Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started working on updating the Linux build a few months ago. It's on branch lpimentel/update-linux-build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this PR, which solution would you prefer:
- Writing our own routine that does simple path appending (you can see that work in some of the recent commits that I reverted)
- Updating the Linux build to take advantage of
std::filesystem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to update the build system right now, starting with the changes from your branch. I'll let you know how that goes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've spent all day trying to update the build system just to use the filesystem::append method but the result is that std::experimental::filesystem is available but not std::filesystem. I'm going to give up on this approach for the PR because I spent an entire day on this already. Unless you can help me take care of that, I will roll our own simple path function for this PR.
| std::vector<WSTRING> GetEnvironmentValues(const WSTRING &name) { | ||
| return GetEnvironmentValues(name, L';'); | ||
| std::vector<WSTRING> GetValues(const WSTRING &delimited_values) { | ||
| return GetValues(delimited_values, L';'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR, but this should really default to ; on Windows and : on Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to change the default behavior right now in this PR, but this would make for a good follow-up PR
…s. Add another unit test to make sure we handle the cases correctly.
…ourselves. Add another unit test to make sure we handle the cases correctly." This reverts commit a676a4f.
… a corresponding unit test
Goal: Use
DD_DOTNET_TRACER_HOMEto locate both definition json file and the managed assemblies for the CLR automatic instrumentation. This eliminates the need for the separateDD_INTEGRATIONSenvironment variable and reduce the number of non-profiler environment variables to 1.This PR does the following:
DD_INTEGRATIONSfrom the Windows MSI.DD_INTEGRATIONSis undefined -- the new default case -- load the integrations file specified at$DD_DOTNET_TRACER_HOME/integrations.jsonDD_DOTNET_TRACER_HOMEis undefined -- which may occur when upgrading the profiler to 1.8.0+ -- infer the location of the managed assemblies on disk from theDD_INTEGRATIONSvariable.@DataDog/apm-dotnet