Skip to content

Commit

Permalink
Refactor the exclude list for assemblies
Browse files Browse the repository at this point in the history
In #1663 we switched from excluding the Microsoft.Extensions prefix to excluding each of the non-logging assemblies individually.

This is not future proof (as new libraries could be added), and increases the number of assemblies we need to match against.

As a workaround, list adds an explicit "include" list for assemblies which match the "exclude" prefix, but which should be included anyway.
  • Loading branch information
andrewlock committed Aug 30, 2022
1 parent 68e01ee commit 692d69b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
11 changes: 11 additions & 0 deletions tracer/src/Datadog.Tracer.Native/cor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,22 @@ HRESULT CorProfiler::TryRejitModule(ModuleID module_id)
{
if (module_info.assembly.name.rfind(skip_assembly_pattern, 0) == 0)
{
// The assembly matches the "skip" prefix, but check if it's specifically included
for (auto&& include_assembly : include_assemblies)
{
if (module_info.assembly.name == include_assembly)
{
Logger::Debug("ModuleLoadFinished matched module by pattern: ", module_id, " ", module_info.assembly.name,
"but assembly is explicitly included");
goto inject;
}
}
Logger::Debug("ModuleLoadFinished skipping module by pattern: ", module_id, " ", module_info.assembly.name);
return S_OK;
}
}

inject:
if (module_info.assembly.name == managed_profiler_name)
{
// Fix PInvoke Rewriting
Expand Down
22 changes: 6 additions & 16 deletions tracer/src/Datadog.Tracer.Native/dd_profiler_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,7 @@ const shared::WSTRING skip_assembly_prefixes[]{
WStr("Microsoft.ApplicationInsights"),
WStr("Microsoft.Build"),
WStr("Microsoft.CSharp"),
WStr("Microsoft.Extensions.Caching"),
WStr("Microsoft.Extensions.Configuration"),
WStr("Microsoft.Extensions.DependencyInjection"),
WStr("Microsoft.Extensions.DependencyModel"),
WStr("Microsoft.Extensions.Diagnostics"),
WStr("Microsoft.Extensions.FileProviders"),
WStr("Microsoft.Extensions.FileSystemGlobbing"),
WStr("Microsoft.Extensions.Hosting"),
WStr("Microsoft.Extensions.Http"),
WStr("Microsoft.Extensions.Identity"),
WStr("Microsoft.Extensions.Localization"),
WStr("Microsoft.Extensions.ObjectPool"),
WStr("Microsoft.Extensions.Options"),
WStr("Microsoft.Extensions.PlatformAbstractions"),
WStr("Microsoft.Extensions.Primitives"),
WStr("Microsoft.Extensions.WebEncoders"),
WStr("Microsoft.Extensions"),
WStr("Microsoft.Web.Compilation.Snapshots"),
WStr("System.Core"),
WStr("System.Console"),
Expand All @@ -66,6 +51,11 @@ const shared::WSTRING skip_assembly_prefixes[]{
WStr("System.Xml"),
};

const shared::WSTRING include_assemblies[]{
WStr("Microsoft.Extensions.Logging"),
WStr("Microsoft.Extensions.Logging.Abstractions"),
};

const shared::WSTRING skip_traceattribute_assembly_prefixes[]{
WStr("System."), WStr("Microsoft."), WStr("Datadog.")};

Expand Down

0 comments on commit 692d69b

Please sign in to comment.