Skip to content

Add fix for whitespace in exporter settings and metrics URL#7747

Merged
bouwkast merged 1 commit intomasterfrom
andrew/fix-exporter-settings
Oct 31, 2025
Merged

Add fix for whitespace in exporter settings and metrics URL#7747
bouwkast merged 1 commit intomasterfrom
andrew/fix-exporter-settings

Conversation

@andrewlock
Copy link
Member

@andrewlock andrewlock commented Oct 31, 2025

Summary of changes

  • Trim whitespace in the exporter settings values before trying to use them
  • Fix a bug where having a whitespace in the DD_DOGSTATSD_SOCKET variable would cause incorrect (and invalid) UDS config

Reason for change

This manifested in a different test in a branch, where an empty string passed in DD_DOGSTATSD_SOCKET was 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?)
  • As we're trimming, we can switch to IsNullOrEmpty instead of IsWhitespace
  • Treat empty DD_DOGSTATSD_SOCKET as not set

Alternatively, we could not trim, stick to using IsWhitespace, and just update the check I fixed to use IsWhitespace 🤷‍♂️

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

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
@andrewlock andrewlock requested a review from a team as a code owner October 31, 2025 17:49
@andrewlock andrewlock added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Oct 31, 2025
// 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))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the actual bug

[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void Metrics_UdsTraceAgent_EmptyDogStatsdSocket_UsesDefaultUdp(string metricsSocket)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test that fails before the fix


[Fact]
public void Metrics_DogStatsdUrl_UdsUnsupported_UsesDefaultUdsOnLinux()
public void Metrics_DogStatsdUrl_UdsUnsupported_UsesDefaultUdpOnLinux()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in the test name

@bouwkast bouwkast enabled auto-merge (squash) October 31, 2025 18:09
@dd-trace-dotnet-ci-bot
Copy link

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:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

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,

Loading
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,

Loading
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,

Loading
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,

Loading
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,

Loading
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,

Loading
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,

Loading
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,

Loading

@bouwkast bouwkast merged commit d5726e6 into master Oct 31, 2025
154 of 155 checks passed
@bouwkast bouwkast deleted the andrew/fix-exporter-settings branch October 31, 2025 20:27
@github-actions github-actions bot added this to the vNext-v3 milestone Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants