Add wildcard support to DD_TRACE_METHODS#2628
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
andrewlock
left a comment
There was a problem hiding this comment.
LGTM, though c++ is not my forte!
|
|
||
| const size_t kPublicKeySize = 8; | ||
| const shared::WSTRING tracemethodintegration_assemblyname = WStr("#TraceMethodFeature"); | ||
| const std::unordered_set<shared::WSTRING> tracemethodintegration_wildcard_ignored_methods( |
There was a problem hiding this comment.
niche, but wondering if we should add Finalize to this list? This has implications if they do have a method called Finalize which isn't a finalizer though, so I'm not sure whether it's a good idea or not.
There was a problem hiding this comment.
In theory we can tell the difference by checking if Finalize() overrides object.Finalize(), but even without that, I agree we should ignore it by default.
There was a problem hiding this comment.
In the latest commits I added Finalize to the list of method names to ignore by default, including ones that aren't finalizers. I don't think this will be an issue for now and we can revisit this later if it becomes an issue
| { | ||
| internal class TestType | ||
| { | ||
| static TestType() { } |
There was a problem hiding this comment.
If you do decide to add Finalize as an ignored method, we should add one here too (and potentially a non-finalizer called Finalize?
…methods: - .cctor - .ctor - Equals - GetHashCode - ToString - All set_* and get_* Unfortunately, if you specify * in your method list, it will ignore your other entries and go into wildcard mode, which stops you from instrumenting getters, setters, etc. The next step is to allow wildcard mode AND allow you to specify special methods that you really do want to instrument
…hods, even if there is a wildcard
…dd logic to sample to try to trigger object finalizer
26780a7 to
5cc9eba
Compare
Code Coverage Report 📊✔️ Merging #2628 into master will not change line coverage
View the full report for further details: Datadog.Trace Breakdown ✔️
The following classes have significant coverage changes.
View the full reports for further details: |
Benchmarks Report 🐌Benchmarks for #2628 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️Raw results
|
Summary of changes
In the first implementation of
DD_TRACE_METHODSfor the .NET Tracer, the developer needed to specify each method in a type to be instrumented. This feature adds the ability to setDD_TRACE_METHODS=TypeName[*]to instrument all methods within a specified type, except the following special methods:.ctor).cctor)EqualsFinalizeGetHashCodeToStringget_XXX/set_XXX)If you want to instrument a special method via
DD_TRACE_METHODSyou must explicitly include it in the configuration. For example, to instrument all methods within a type namedType1, all of the special methods listed above, and the getter/setter for a property namedName, the configuration would beDD_TRACE_METHODS=Type1[*,.ctor,.cctor,Equals,GetHashCode,ToString,get_Name,set_Name]Reason for change
It can be error-prone to configure a large number of methods within one type, so a wildcard character
*lowers the burden for configuration.Implementation details
The implementation has two steps:
DD_TRACE_METHODSconfiguration: There is no special parsing to handle the*method specifier, it just generates anIntegrationDefinitionobject like all other strings.RejitPreprocessor<RejitRequestDefinition>::ProcessTypeDefForRejit, allow the method name*to enumerate all methods for a typeDef (metadataImport->EnumMethods) instead of enumerating the methods with a specific method (metadataImport->EnumMethodsWithName). When processing the methods from the*method search, do string comparisons and string finds to exclude the special methods above.Test coverage
IntegrationDefinition.*wildcard and a special method (property getter) is added and tested for span-ification.Other details
N/A