Fix invalid telemetry when using manual config in code with dictionaries#8022
Fix invalid telemetry when using manual config in code with dictionaries#8022andrewlock merged 5 commits intomasterfrom
Conversation
.../src/Datadog.Trace/Configuration/ConfigurationSources/DictionaryObjectConfigurationSource.cs
Show resolved
Hide resolved
| @@ -189,38 +189,17 @@ public ConfigurationResult<bool> GetBool(string key, IConfigurationTelemetry tel | |||
|
|
|||
| /// <inheritdoc /> | |||
| public ConfigurationResult<IDictionary<string, string>> GetDictionary(string key, IConfigurationTelemetry telemetry, Func<IDictionary<string, string>, bool>? validator) | |||
There was a problem hiding this comment.
These methods were essentially identical except for the GetDictionary() call (which all called different overloads)
| { | ||
| telemetry.Record(key, result.TelemetryOverride ?? result.Result?.ToString(), recordValue: true, origin); | ||
| // there should always be a telemetry override by convention, so just record a sentinel for now if there's not for some reason | ||
| telemetry.Record(key, result.TelemetryOverride ?? "<MISSING>", recordValue: true, origin); |
There was a problem hiding this comment.
We should never hit this path, but if we do, calling ToString() on a dictionary is pointless. We could serialize it properly, but seeing as this shouldn't ever be hit (we should always have a fallback), it doesn't seem worth duplicating here to me
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8022) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (69ms) : 67, 70
master - mean (68ms) : 67, 70
section Bailout
This PR (8022) - mean (72ms) : 71, 73
master - mean (72ms) : 71, 74
section CallTarget+Inlining+NGEN
This PR (8022) - mean (1,008ms) : 971, 1045
master - mean (1,013ms) : 948, 1078
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (106ms) : 104, 109
master - mean (105ms) : 103, 108
section Bailout
This PR (8022) - mean (107ms) : 106, 108
master - mean (107ms) : 105, 108
section CallTarget+Inlining+NGEN
This PR (8022) - mean (744ms) : 684, 805
master - mean (735ms) : 667, 804
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (94ms) : 91, 96
master - mean (93ms) : 91, 95
section Bailout
This PR (8022) - mean (95ms) : 93, 96
master - mean (94ms) : 93, 95
section CallTarget+Inlining+NGEN
This PR (8022) - mean (710ms) : 659, 762
master - mean (708ms) : 671, 745
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (92ms) : 90, 94
master - mean (92ms) : 90, 94
section Bailout
This PR (8022) - mean (93ms) : 92, 95
master - mean (93ms) : 92, 94
section CallTarget+Inlining+NGEN
This PR (8022) - mean (637ms) : 620, 654
master - mean (634ms) : 617, 650
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (195ms) : 191, 199
master - mean (194ms) : 190, 198
section Bailout
This PR (8022) - mean (198ms) : 194, 202
master - mean (197ms) : 193, 201
section CallTarget+Inlining+NGEN
This PR (8022) - mean (1,110ms) : 1063, 1158
master - mean (1,112ms) : 1054, 1170
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (279ms) : 271, 288
master - mean (276ms) : 272, 281
section Bailout
This PR (8022) - mean (279ms) : 274, 285
master - mean (277ms) : 274, 280
section CallTarget+Inlining+NGEN
This PR (8022) - mean (924ms) : 871, 976
master - mean (925ms) : 883, 967
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (271ms) : 265, 278
master - mean (270ms) : 266, 274
section Bailout
This PR (8022) - mean (271ms) : 267, 276
master - mean (270ms) : 267, 273
section CallTarget+Inlining+NGEN
This PR (8022) - mean (932ms) : 901, 963
master - mean (931ms) : 898, 964
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8022) - mean (272ms) : 266, 278
master - mean (269ms) : 264, 275
section Bailout
This PR (8022) - mean (270ms) : 266, 274
master - mean (270ms) : 266, 274
section CallTarget+Inlining+NGEN
This PR (8022) - mean (829ms) : 807, 851
master - mean (822ms) : 807, 837
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
d2648ba to
b15e9e9
Compare
BenchmarksBenchmark execution time: 2026-01-09 12:41:12 Comparing candidate commit b15e9e9 in PR branch Found 4 performance improvements and 11 performance regressions! Performance is the same for 158 metrics, 13 unstable metrics. scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1
scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1
scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0
|
…ies (#8022) ## Summary of changes Fixes a bug in telemetry that was recording invalid values for dictionary values coming from config-in-code ## Reason for change When looking through some memory dumps, noticed a bunch of strings that looked like `"DD_TAGS:System.Collections.Generic.Dictionary``2[System.String,System.String]"` and tracked them down to the manual config, and ultimately to a bug in the `DictionaryObjectConfigurationSource.AsDictionary()` methods. ## Implementation details - Write some unit tests to track down the problem. Show them failing with above string. - Minor refactor of `CompositeConfigurationSource.AsDictionary()` to reduce duplication - Fix bug in `DictionaryObjectConfigurationSource` - Simplify (unused except in error) fallback path in `CompositeConfigurationSource.AsDictionary()` ## Test coverage Added unit tests to demonstrate bug
Summary of changes
Fixes a bug in telemetry that was recording invalid values for dictionary values coming from config-in-code
Reason for change
When looking through some memory dumps, noticed a bunch of strings that looked like
"DD_TAGS:System.Collections.Generic.Dictionary``2[System.String,System.String]"and tracked them down to the manual config, and ultimately to a bug in theDictionaryObjectConfigurationSource.AsDictionary()methods.Implementation details
CompositeConfigurationSource.AsDictionary()to reduce duplicationDictionaryObjectConfigurationSourceCompositeConfigurationSource.AsDictionary()Test coverage
Added unit tests to demonstrate bug