Skip to content

Commit f2b0595

Browse files
authored
Merge branch 'master' into andrew/update-linux-app-pools
2 parents fe88c2d + a84982f commit f2b0595

File tree

10 files changed

+237
-221
lines changed

10 files changed

+237
-221
lines changed

tracer/src/Datadog.Tracer.Native/cor_profiler.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::AssemblyLoadFinished(AssemblyID assembly_
460460
{
461461
Logger::Info("AssemblyLoadFinished: Datadog.Trace.dll v", assembly_version, " matched profiler version v",
462462
expected_version);
463-
managed_profiler_loaded_app_domains.insert({assembly_info.app_domain_id, assembly_metadata.version});
463+
managed_profiler_loaded_app_domains.insert({assembly_info.app_domain_id, assembly_info.manifest_module_id});
464464

465465
// Load defaults values if the version are the same as expected
466466
if (assembly_metadata.version == expected_assembly_reference.version)
@@ -481,7 +481,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::AssemblyLoadFinished(AssemblyID assembly_
481481
if (assembly_info.app_domain_id == corlib_app_domain_id)
482482
{
483483
Logger::Info("AssemblyLoadFinished: Datadog.Trace.dll was loaded domain-neutral");
484-
managed_profiler_loaded_domain_neutral = true;
484+
managed_profiler_domain_neutral_module_id = assembly_info.manifest_module_id;
485485
}
486486
else
487487
{
@@ -2503,10 +2503,27 @@ bool CorProfiler::GetIntegrationTypeRef(ModuleMetadata& module_metadata, ModuleI
25032503

25042504
bool CorProfiler::ProfilerAssemblyIsLoadedIntoAppDomain(AppDomainID app_domain_id)
25052505
{
2506-
return managed_profiler_loaded_domain_neutral ||
2506+
return managed_profiler_domain_neutral_module_id > 0 ||
25072507
managed_profiler_loaded_app_domains.find(app_domain_id) != managed_profiler_loaded_app_domains.end();
25082508
}
25092509

2510+
ModuleID CorProfiler::GetProfilerAssemblyModuleId(AppDomainID appDomainId)
2511+
{
2512+
if (managed_profiler_domain_neutral_module_id > 0)
2513+
{
2514+
return managed_profiler_domain_neutral_module_id;
2515+
}
2516+
2517+
auto it = managed_profiler_loaded_app_domains.find(appDomainId);
2518+
if (it != managed_profiler_loaded_app_domains.end())
2519+
{
2520+
return it->second;
2521+
}
2522+
2523+
return 0;
2524+
}
2525+
2526+
25102527
HRESULT CorProfiler::EmitDistributedTracerTargetMethod(const ModuleMetadata& module_metadata, ModuleID module_id)
25112528
{
25122529
// Emit a public DistributedTracer.__GetInstanceForProfiler__() method, that will be used by RewriteForDistributedTracing

tracer/src/Datadog.Tracer.Native/cor_profiler.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class CorProfiler : public CorProfilerBase
6262
bool corlib_module_loaded = false;
6363
ModuleID corlib_module_id = 0;
6464
AppDomainID corlib_app_domain_id = 0;
65-
bool managed_profiler_loaded_domain_neutral = false;
66-
std::unordered_map<AppDomainID, Version> managed_profiler_loaded_app_domains;
65+
ModuleID managed_profiler_domain_neutral_module_id = 0;
66+
std::unordered_map<AppDomainID, ModuleID> managed_profiler_loaded_app_domains;
6767
std::unordered_set<AppDomainID> first_jit_compilation_app_domains;
6868
bool is_desktop_iis = false;
6969

@@ -255,6 +255,11 @@ class CorProfiler : public CorProfilerBase
255255
//
256256
bool IsCallTargetBubbleUpExceptionTypeAvailable() const;
257257
bool IsCallTargetBubbleUpFunctionAvailable() const;
258+
259+
//
260+
// Dataflow helper methods
261+
//
262+
ModuleID GetProfilerAssemblyModuleId(AppDomainID appDomainId);
258263
};
259264

260265
// Note: Generally you should not have a single, global callback implementation,

0 commit comments

Comments
 (0)