Skip to content

[Feature Flags] Fix ISO 8601 date parsing to support variable precision#8094

Merged
leoromanovsky merged 7 commits intomasterfrom
leo/fix-iso8601-date-parsing
Jan 23, 2026
Merged

[Feature Flags] Fix ISO 8601 date parsing to support variable precision#8094
leoromanovsky merged 7 commits intomasterfrom
leo/fix-iso8601-date-parsing

Conversation

@leoromanovsky
Copy link
Contributor

The date parser was using TryParseExact with a fixed 3-digit millisecond format, causing PARSE_ERROR for dates with 6-digit microsecond precision (e.g., "2025-09-23T15:48:37.235982Z") sent by the backend.

Changed to use DateTime.TryParse with DateTimeStyles.RoundtripKind which correctly handles all valid ISO 8601 date formats including:

  • No fractional seconds: 2020-01-01T00:00:00Z
  • 1-7 digit fractional seconds (beyond 7 digits truncated by .NET)

Added comprehensive unit tests for various date precisions and invalid date handling. Also added microsecond-date-test flag and test cases to the bundled test data.

Summary of changes

Reason for change

Implementation details

Test coverage

Associating a new system test (also discovered this condition in java): DataDog/system-tests#6087

Other details

The date parser was using TryParseExact with a fixed 3-digit millisecond
format, causing PARSE_ERROR for dates with 6-digit microsecond precision
(e.g., "2025-09-23T15:48:37.235982Z") sent by the backend.

Changed to use DateTime.TryParse with DateTimeStyles.RoundtripKind which
correctly handles all valid ISO 8601 date formats including:
- No fractional seconds: 2020-01-01T00:00:00Z
- 1-7 digit fractional seconds (beyond 7 digits truncated by .NET)

Added comprehensive unit tests for various date precisions and invalid
date handling. Also added microsecond-date-test flag and test cases
to the bundled test data.
@pr-commenter
Copy link

pr-commenter bot commented Jan 22, 2026

Benchmarks

Benchmark execution time: 2026-01-23 19:01:34

Comparing candidate commit 258a256 in PR branch leo/fix-iso8601-date-parsing with baseline commit a7f09d3 in branch master.

Found 1 performance improvements and 5 performance regressions! Performance is the same for 165 metrics, 21 unstable metrics.

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟩 throughput [+118.948op/s; +205.780op/s] or [+9.095%; +15.734%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0

  • 🟥 execution_time [+66.066µs; +71.014µs] or [+6.431%; +6.913%]
  • 🟥 throughput [-63.047op/s; -58.730op/s] or [-6.476%; -6.033%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 execution_time [+11.248ms; +14.954ms] or [+5.761%; +7.660%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+23.354ms; +27.217ms] or [+13.330%; +15.534%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

  • 🟥 execution_time [+10.590ms; +15.125ms] or [+5.390%; +7.698%]

@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Jan 22, 2026

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8094) and master.

⚠️ Potential regressions detected

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.51 ± (68.51 - 68.72) ms72.34 ± (73.88 - 75.51) ms+5.6%❌⬆️
Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.51 ± (68.51 - 68.72) ms72.34 ± (73.88 - 75.51) ms+5.6%❌⬆️
.NET Framework 4.8 - Bailout
duration72.26 ± (72.11 - 72.37) ms76.58 ± (76.65 - 77.39) ms+6.0%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1002.32 ± (1012.44 - 1023.99) ms1003.43 ± (1008.67 - 1017.31) ms+0.1%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.78 ± (21.74 - 21.81) ms21.97 ± (21.95 - 22.00) ms+0.9%✅⬆️
process.time_to_main_ms78.73 ± (78.57 - 78.90) ms78.96 ± (78.80 - 79.12) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.90 ± (10.90 - 10.91) MB10.90 ± (10.89 - 10.90) MB-0.1%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.73 ± (21.71 - 21.75) ms21.88 ± (21.86 - 21.91) ms+0.7%✅⬆️
process.time_to_main_ms79.97 ± (79.87 - 80.07) ms80.17 ± (80.06 - 80.28) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.95 ± (10.94 - 10.95) MB10.93 ± (10.92 - 10.93) MB-0.2%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms251.62 ± (248.50 - 254.74) ms247.55 ± (243.93 - 251.18) ms-1.6%
process.time_to_main_ms471.84 ± (471.18 - 472.49) ms473.70 ± (472.90 - 474.50) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.39 ± (48.36 - 48.41) MB48.38 ± (48.35 - 48.40) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.4%
.NET 6 - Baseline
process.internal_duration_ms20.64 ± (20.62 - 20.67) ms20.77 ± (20.74 - 20.80) ms+0.6%✅⬆️
process.time_to_main_ms68.44 ± (68.34 - 68.54) ms68.54 ± (68.42 - 68.67) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.61 - 10.62) MB10.62 ± (10.62 - 10.62) MB+0.0%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.52 ± (20.50 - 20.54) ms20.69 ± (20.66 - 20.71) ms+0.8%✅⬆️
process.time_to_main_ms69.16 ± (69.11 - 69.21) ms69.57 ± (69.50 - 69.63) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.66 ± (10.66 - 10.67) MB10.72 ± (10.72 - 10.73) MB+0.5%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms244.45 ± (242.06 - 246.83) ms247.99 ± (245.91 - 250.07) ms+1.4%✅⬆️
process.time_to_main_ms447.00 ± (446.46 - 447.54) ms449.35 ± (448.77 - 449.93) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.15 ± (49.12 - 49.18) MB49.13 ± (49.11 - 49.16) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.1%
.NET 8 - Baseline
process.internal_duration_ms18.81 ± (18.78 - 18.84) ms18.85 ± (18.83 - 18.88) ms+0.2%✅⬆️
process.time_to_main_ms67.26 ± (67.16 - 67.35) ms67.58 ± (67.47 - 67.68) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.65 ± (7.64 - 7.66) MB7.69 ± (7.68 - 7.70) MB+0.6%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.78 ± (18.76 - 18.81) ms18.87 ± (18.85 - 18.89) ms+0.5%✅⬆️
process.time_to_main_ms68.37 ± (68.31 - 68.44) ms68.71 ± (68.64 - 68.77) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.71 ± (7.70 - 7.71) MB7.75 ± (7.74 - 7.76) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms177.33 ± (176.47 - 178.19) ms178.68 ± (177.68 - 179.68) ms+0.8%✅⬆️
process.time_to_main_ms430.32 ± (429.52 - 431.12) ms431.92 ± (431.22 - 432.62) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.54 ± (36.51 - 36.57) MB36.57 ± (36.54 - 36.60) MB+0.1%✅⬆️
runtime.dotnet.threads.count27 ± (26 - 27)26 ± (26 - 26)-0.0%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration193.66 ± (193.44 - 194.16) ms194.22 ± (194.39 - 195.20) ms+0.3%✅⬆️
.NET Framework 4.8 - Bailout
duration197.07 ± (196.90 - 197.47) ms197.60 ± (197.49 - 198.12) ms+0.3%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1136.56 ± (1138.57 - 1149.46) ms1130.61 ± (1134.86 - 1144.61) ms-0.5%
.NET Core 3.1 - Baseline
process.internal_duration_ms187.90 ± (187.53 - 188.27) ms187.98 ± (187.68 - 188.27) ms+0.0%✅⬆️
process.time_to_main_ms81.02 ± (80.77 - 81.26) ms81.96 ± (81.71 - 82.21) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.08 ± (16.05 - 16.11) MB16.08 ± (16.05 - 16.10) MB-0.0%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.2%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms188.45 ± (188.03 - 188.87) ms187.92 ± (187.57 - 188.26) ms-0.3%
process.time_to_main_ms82.80 ± (82.59 - 83.00) ms82.98 ± (82.81 - 83.16) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.13 ± (16.11 - 16.16) MB16.10 ± (16.07 - 16.12) MB-0.2%
runtime.dotnet.threads.count21 ± (20 - 21)21 ± (20 - 21)-0.1%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms435.57 ± (432.95 - 438.20) ms427.66 ± (424.75 - 430.58) ms-1.8%
process.time_to_main_ms473.27 ± (472.70 - 473.85) ms475.85 ± (475.17 - 476.53) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.76 ± (58.64 - 58.87) MB58.75 ± (58.63 - 58.87) MB-0.0%
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.1%
.NET 6 - Baseline
process.internal_duration_ms191.68 ± (191.35 - 192.01) ms192.73 ± (192.41 - 193.05) ms+0.5%✅⬆️
process.time_to_main_ms69.98 ± (69.78 - 70.18) ms70.67 ± (70.42 - 70.91) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed15.81 ± (15.64 - 15.98) MB16.15 ± (16.03 - 16.26) MB+2.1%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 19)+1.5%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.24 ± (190.90 - 191.57) ms192.41 ± (191.95 - 192.87) ms+0.6%✅⬆️
process.time_to_main_ms71.15 ± (71.02 - 71.28) ms71.93 ± (71.73 - 72.13) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.16 ± (16.03 - 16.30) MB16.20 ± (16.08 - 16.32) MB+0.2%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (20 - 20)+2.3%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms442.87 ± (439.56 - 446.18) ms448.20 ± (444.53 - 451.87) ms+1.2%✅⬆️
process.time_to_main_ms450.86 ± (450.37 - 451.35) ms459.49 ± (458.48 - 460.51) ms+1.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed59.03 ± (58.91 - 59.14) MB58.78 ± (58.63 - 58.93) MB-0.4%
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.3%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms190.37 ± (190.03 - 190.71) ms193.03 ± (192.57 - 193.48) ms+1.4%✅⬆️
process.time_to_main_ms69.98 ± (69.79 - 70.17) ms70.94 ± (70.76 - 71.12) ms+1.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.73 ± (11.70 - 11.75) MB11.72 ± (11.70 - 11.74) MB-0.1%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.8%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms189.61 ± (189.28 - 189.94) ms191.20 ± (190.87 - 191.54) ms+0.8%✅⬆️
process.time_to_main_ms71.26 ± (71.15 - 71.36) ms72.00 ± (71.85 - 72.15) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.80 ± (11.78 - 11.83) MB11.78 ± (11.75 - 11.81) MB-0.2%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.1%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms368.05 ± (366.32 - 369.77) ms370.51 ± (368.96 - 372.05) ms+0.7%✅⬆️
process.time_to_main_ms436.90 ± (436.18 - 437.62) ms439.66 ± (438.87 - 440.46) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed48.15 ± (48.11 - 48.19) MB48.15 ± (48.10 - 48.20) MB+0.0%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.2%
Comparison explanation

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 highlighted 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).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8094) - mean (75ms)  : 63, 86
    master - mean (69ms)  : 67, 70

    section Bailout
    This PR (8094) - mean (77ms)  : 72, 82
    master - mean (72ms)  : 71, 74

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (1,013ms)  : 952, 1074
    master - mean (1,018ms)  : 933, 1104

Loading
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 (8094) - mean (106ms)  : 104, 109
    master - mean (106ms)  : 103, 109

    section Bailout
    This PR (8094) - mean (107ms)  : 105, 109
    master - mean (107ms)  : 105, 108

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (742ms)  : 680, 805
    master - mean (748ms)  : 703, 794

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8094) - mean (94ms)  : 91, 97
    master - mean (94ms)  : 92, 96

    section Bailout
    This PR (8094) - mean (95ms)  : 94, 96
    master - mean (94ms)  : 93, 95

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (721ms)  : 692, 751
    master - mean (716ms)  : 680, 752

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8094) - mean (92ms)  : 90, 95
    master - mean (92ms)  : 89, 95

    section Bailout
    This PR (8094) - mean (94ms)  : 93, 95
    master - mean (93ms)  : 92, 94

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (638ms)  : 622, 654
    master - mean (635ms)  : 622, 648

Loading
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 (8094) - mean (195ms)  : 190, 199
    master - mean (194ms)  : 190, 197

    section Bailout
    This PR (8094) - mean (198ms)  : 195, 201
    master - mean (197ms)  : 195, 200

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (1,140ms)  : 1069, 1210
    master - mean (1,144ms)  : 1061, 1227

Loading
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 (8094) - mean (279ms)  : 274, 284
    master - mean (278ms)  : 272, 283

    section Bailout
    This PR (8094) - mean (279ms)  : 273, 285
    master - mean (280ms)  : 271, 288

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (933ms)  : 886, 981
    master - mean (936ms)  : 901, 972

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8094) - mean (272ms)  : 265, 278
    master - mean (270ms)  : 265, 275

    section Bailout
    This PR (8094) - mean (273ms)  : 265, 281
    master - mean (271ms)  : 266, 276

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (938ms)  : 875, 1000
    master - mean (924ms)  : 879, 969

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8094) - mean (274ms)  : 265, 284
    master - mean (270ms)  : 265, 275

    section Bailout
    This PR (8094) - mean (273ms)  : 269, 278
    master - mean (270ms)  : 266, 275

    section CallTarget+Inlining+NGEN
    This PR (8094) - mean (841ms)  : 819, 863
    master - mean (836ms)  : 815, 857

Loading

@leoromanovsky leoromanovsky marked this pull request as ready for review January 22, 2026 17:58
@leoromanovsky leoromanovsky requested review from a team as code owners January 22, 2026 17:58
}

throw new FormatException("Wrong date format");
throw new FormatException($"Wrong date format: {dateString}");
Copy link
Member

@lucaspimentel lucaspimentel Jan 22, 2026

Choose a reason for hiding this comment

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

If we're always going to throw an exception when the format is invalid, any reason not use to Parse() (which throws FormatException) instead of TryParse()?

@leoromanovsky leoromanovsky requested a review from a team as a code owner January 23, 2026 14:33
Copy link

@typotter typotter left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, Leo. Knocks off another inconsistency between the SDKs and backed by system tests too!
LGTM modulo the switch to Parse instead of TryParse so we can let the root exception propagate.

@typotter typotter assigned leoromanovsky and unassigned typotter Jan 23, 2026
@leoromanovsky leoromanovsky removed the request for review from a team January 23, 2026 18:47
@leoromanovsky leoromanovsky merged commit aaaf6e1 into master Jan 23, 2026
149 of 150 checks passed
@leoromanovsky leoromanovsky deleted the leo/fix-iso8601-date-parsing branch January 23, 2026 20:01
@github-actions github-actions bot added this to the vNext-v3 milestone Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants