Add fix for whitespace in exporter settings and metrics URL#7747
Add fix for whitespace in exporter settings and metrics URL#7747
Conversation
This manifested in a different test where an empty string passed as the DogStatsD socket was causing us to use UDS even through it's not available and not _really_ set
| // For some cases, we allow falling back on another configuration (eg invalid url as the application will need to be restarted to fix it anyway). | ||
| // For other cases (eg a configured unix domain socket path not found), we don't fallback as the problem could be fixed outside the application. | ||
| if (!string.IsNullOrWhiteSpace(agentUri)) | ||
| if (!string.IsNullOrEmpty(agentUri)) |
There was a problem hiding this comment.
If we're trimming, we only need to check for empty
| settings = new MetricsTransportSettings(TransportType.NamedPipe, PipeName: metricsPipeName); | ||
| } | ||
| else if (metricsUnixDomainSocketPath != null) | ||
| else if (!string.IsNullOrEmpty(metricsUnixDomainSocketPath)) |
There was a problem hiding this comment.
This fixes the actual bug
| [InlineData(null)] | ||
| [InlineData("")] | ||
| [InlineData(" ")] | ||
| public void Metrics_UdsTraceAgent_EmptyDogStatsdSocket_UsesDefaultUdp(string metricsSocket) |
There was a problem hiding this comment.
This is the test that fails before the fix
|
|
||
| [Fact] | ||
| public void Metrics_DogStatsdUrl_UdsUnsupported_UsesDefaultUdsOnLinux() | ||
| public void Metrics_DogStatsdUrl_UdsUnsupported_UsesDefaultUdpOnLinux() |
There was a problem hiding this comment.
typo in the test name
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-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 shown 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). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (72ms) : 71, 73
. : milestone, 72,
master - mean (72ms) : 71, 73
. : milestone, 72,
section Baseline
This PR (7747) - mean (68ms) : 66, 70
. : milestone, 68,
master - mean (68ms) : 67, 70
. : milestone, 68,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (1,047ms) : 999, 1096
. : milestone, 1047,
master - mean (1,045ms) : 1004, 1087
. : milestone, 1045,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (107ms) : 105, 108
. : milestone, 107,
master - mean (107ms) : 105, 108
. : milestone, 107,
section Baseline
This PR (7747) - mean (105ms) : 103, 108
. : milestone, 105,
master - mean (106ms) : 104, 108
. : milestone, 106,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (748ms) : 726, 770
. : milestone, 748,
master - mean (749ms) : 719, 780
. : milestone, 749,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (94ms) : 93, 95
. : milestone, 94,
master - mean (94ms) : 93, 95
. : milestone, 94,
section Baseline
This PR (7747) - mean (93ms) : 91, 95
. : milestone, 93,
master - mean (94ms) : 92, 96
. : milestone, 94,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (710ms) : 672, 747
. : milestone, 710,
master - mean (708ms) : 670, 745
. : milestone, 708,
gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (93ms) : 91, 94
. : milestone, 93,
master - mean (93ms) : 91, 95
. : milestone, 93,
section Baseline
This PR (7747) - mean (92ms) : 89, 94
. : milestone, 92,
master - mean (92ms) : 90, 94
. : milestone, 92,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (659ms) : 643, 674
. : milestone, 659,
master - mean (664ms) : 649, 679
. : milestone, 664,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (196ms) : 194, 198
. : milestone, 196,
master - mean (196ms) : 192, 201
. : milestone, 196,
section Baseline
This PR (7747) - mean (194ms) : 190, 198
. : milestone, 194,
master - mean (193ms) : 189, 196
. : milestone, 193,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (1,170ms) : 1109, 1232
. : milestone, 1170,
master - mean (1,175ms) : 1099, 1250
. : milestone, 1175,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (278ms) : 274, 283
. : milestone, 278,
master - mean (277ms) : 273, 281
. : milestone, 277,
section Baseline
This PR (7747) - mean (283ms) : 274, 293
. : milestone, 283,
master - mean (277ms) : 272, 282
. : milestone, 277,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (963ms) : 912, 1014
. : milestone, 963,
master - mean (957ms) : 905, 1008
. : milestone, 957,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (270ms) : 266, 274
. : milestone, 270,
master - mean (269ms) : 265, 273
. : milestone, 269,
section Baseline
This PR (7747) - mean (271ms) : 265, 276
. : milestone, 271,
master - mean (270ms) : 265, 275
. : milestone, 270,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (944ms) : 887, 1002
. : milestone, 944,
master - mean (933ms) : 873, 992
. : milestone, 933,
gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat X
axisFormat %s
todayMarker off
section Bailout
This PR (7747) - mean (274ms) : 266, 282
. : milestone, 274,
master - mean (270ms) : 264, 275
. : milestone, 270,
section Baseline
This PR (7747) - mean (273ms) : 265, 281
. : milestone, 273,
master - mean (268ms) : 263, 273
. : milestone, 268,
section CallTarget+Inlining+NGEN
This PR (7747) - mean (861ms) : 837, 885
. : milestone, 861,
master - mean (855ms) : 837, 873
. : milestone, 855,
|
Summary of changes
DD_DOGSTATSD_SOCKETvariable would cause incorrect (and invalid) UDS configReason for change
This manifested in a different test in a branch, where an empty string passed in
DD_DOGSTATSD_SOCKETwas causing us to use UDS for metrics even through it's not available and not really set.Implementation details
Trim()the string variables (I don't think there's a good reason not to?)IsNullOrEmptyinstead ofIsWhitespaceDD_DOGSTATSD_SOCKETas not setAlternatively, we could not trim, stick to using
IsWhitespace, and just update the check I fixed to useIsWhitespace🤷♂️Test coverage
Added a couple of unit tests. Only one test is for this specific issue, the others were just part of my investigation, and seemed reasonable.
Other details
Discovered as part of #7724 and https://datadoghq.atlassian.net/browse/LANGPLAT-819