Skip to content

Fix Environment.Version causing huge allocation#8068

Merged
andrewlock merged 2 commits intomasterfrom
andrew/fix-environment-version
Jan 15, 2026
Merged

Fix Environment.Version causing huge allocation#8068
andrewlock merged 2 commits intomasterfrom
andrew/fix-environment-version

Conversation

@andrewlock
Copy link
Member

Summary of changes

  • Don't call Environment.Version except in FrameworkDescription
  • Fix ActivityEnumerationHelper to use FrameworkDescription instead of Environment.Version

Reason for change

Environment.Version allocates every time you access it. So my "improve performance by checking if we're in .NET 10" PR caused a massive allocation regression 💀 😂

image

So I think it makes sense to cache Environment.Version in our FrameworkDescription type, and access it from there.

Implementation details

  • Read (or calculate, where it can't be trusted) the Environment.Version for the app in FrameworkDescription
  • Expose it as FrameworkDescription.RuntimeVersion
  • Use the exposed version where possible
  • Add #nullable enable seeing as I need to think about all that properly anyway

Test coverage

This fixes the benchmarks again now 🙄 Everything else should be covered by existing, but I'll likely follow up with some more tests in a follow up PR (just don't want to delay this getting in!)

Other details

The benchmarks did show the regression in the PR #8058... but I wasn't looking, because those numbers are so flaky 😬

@andrewlock andrewlock requested a review from a team as a code owner January 15, 2026 15:29
@andrewlock andrewlock added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Jan 15, 2026
@andrewlock andrewlock requested review from a team as code owners January 15, 2026 15:29
@andrewlock andrewlock added the type:performance Performance, speed, latency, resource usage (CPU, memory) label Jan 15, 2026
@andrewlock andrewlock requested a review from anna-git January 15, 2026 15:29
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(ActivityEnumerationHelper));

private static readonly bool IsDotNet10
#if NET10_0_OR_GREATER
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't build for this now, but maybe we will in the future, so why not


private static readonly Assembly RootAssembly = typeof(object).Assembly;

private static readonly Tuple<int, string>[] DotNetFrameworkVersionMapping =
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of allocating this array, then enumerating it using linq, just converted into a big switch statement below

Comment on lines +19 to +21
private static readonly Lazy<FrameworkDescription> _instance = new(Create);

public static FrameworkDescription Instance
{
get { return _instance ?? (_instance = Create()); }
}
public static FrameworkDescription Instance => _instance.Value;
Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't really see a reason that we were doing this in a "fake lazy" way 🤔 I think we can get rid of the Lazy<T> too, but it seemed safer to not, just in case

private static string GetNetCoreOrNetFrameworkVersion()
private static void GetNetCoreOrNetFrameworkVersion(out Version version, out string productVersion)
{
string productVersion = null;
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes basically just grab Environment.Version now or if it can't be trusted, try to parse it from the calculated productVersion

Copy link
Collaborator

@bouwkast bouwkast left a comment

Choose a reason for hiding this comment

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

LGTM


public static bool IsNet5()
{
return Environment.Version.Major >= 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this Environment.Version an issue as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, fixed in #8069, just didn't want to delay getting this fix in 😄

@pr-commenter
Copy link

pr-commenter bot commented Jan 15, 2026

Benchmarks

Benchmark execution time: 2026-01-15 16:11:41

Comparing candidate commit c83799b in PR branch andrew/fix-environment-version with baseline commit 31949a5 in branch master.

Found 9 performance improvements and 7 performance regressions! Performance is the same for 164 metrics, 12 unstable metrics.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0

  • 🟩 throughput [+81210.531op/s; +82628.636op/s] or [+190.315%; +193.639%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1

  • 🟩 throughput [+8575.593op/s; +9993.458op/s] or [+9.691%; +11.293%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 execution_time [+15.989ms; +22.423ms] or [+8.215%; +11.521%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-21.165ms; -14.910ms] or [-9.814%; -6.914%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • 🟥 execution_time [+55.370ms; +57.309ms] or [+57.055%; +59.052%]

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

  • 🟩 execution_time [-17.627ms; -12.975ms] or [-11.322%; -8.334%]
  • 🟩 throughput [+235.193op/s; +281.233op/s] or [+17.576%; +21.017%]

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

  • 🟥 execution_time [+83.499µs; +90.715µs] or [+7.975%; +8.664%]
  • 🟥 throughput [-76.368op/s; -70.353op/s] or [-7.995%; -7.366%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • 🟩 throughput [+35786.344op/s; +53820.527op/s] or [+6.254%; +9.406%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟩 throughput [+22292.178op/s; +30776.472op/s] or [+5.487%; +7.576%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • 🟩 execution_time [-7.496µs; -2.958µs] or [-14.195%; -5.602%]
  • 🟩 throughput [+1207.959op/s; +2620.330op/s] or [+6.298%; +13.661%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472

  • 🟥 throughput [-23211.959op/s; -21471.737op/s] or [-6.754%; -6.248%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟥 execution_time [+13.423ms; +17.136ms] or [+6.770%; +8.642%]

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

  • 🟥 execution_time [+10.162ms; +14.409ms] or [+5.187%; +7.355%]

@andrewlock andrewlock enabled auto-merge (squash) January 15, 2026 16:28
@dd-trace-dotnet-ci-bot
Copy link

Execution-Time Benchmarks Report ⏱️

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

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration68.29 ± (68.31 - 68.51) ms68.27 ± (68.29 - 68.50) ms-0.0%
.NET Framework 4.8 - Bailout
duration72.23 ± (72.17 - 72.39) ms72.12 ± (72.05 - 72.27) ms-0.2%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1000.16 ± (1004.02 - 1012.69) ms1003.72 ± (1013.73 - 1025.35) ms+0.4%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.92 ± (21.88 - 21.95) ms21.87 ± (21.84 - 21.90) ms-0.2%
process.time_to_main_ms79.00 ± (78.84 - 79.16) ms78.84 ± (78.65 - 79.03) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.90 ± (10.90 - 10.91) MB10.91 ± (10.91 - 10.92) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.90 ± (21.88 - 21.92) ms21.79 ± (21.77 - 21.81) ms-0.5%
process.time_to_main_ms79.67 ± (79.57 - 79.77) ms79.79 ± (79.70 - 79.88) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.94 ± (10.94 - 10.95) MB10.95 ± (10.94 - 10.95) MB+0.0%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms260.34 ± (259.11 - 261.57) ms240.53 ± (236.86 - 244.20) ms-7.6%
process.time_to_main_ms468.84 ± (468.41 - 469.28) ms469.80 ± (469.30 - 470.30) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.47 ± (48.45 - 48.49) MB48.39 ± (48.37 - 48.42) MB-0.2%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.1%
.NET 6 - Baseline
process.internal_duration_ms20.65 ± (20.62 - 20.69) ms20.61 ± (20.58 - 20.64) ms-0.2%
process.time_to_main_ms68.44 ± (68.28 - 68.59) ms67.99 ± (67.88 - 68.11) ms-0.6%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.63) MB10.63 ± (10.63 - 10.63) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.51 ± (20.49 - 20.53) ms20.51 ± (20.49 - 20.54) ms+0.0%✅⬆️
process.time_to_main_ms69.02 ± (68.96 - 69.08) ms68.86 ± (68.80 - 68.92) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.72 ± (10.72 - 10.73) MB10.75 ± (10.74 - 10.77) MB+0.3%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms249.58 ± (248.51 - 250.66) ms248.44 ± (246.81 - 250.08) ms-0.5%
process.time_to_main_ms445.15 ± (444.65 - 445.65) ms446.82 ± (446.36 - 447.28) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.20 ± (49.17 - 49.23) MB49.12 ± (49.09 - 49.15) MB-0.2%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.1%
.NET 8 - Baseline
process.internal_duration_ms18.80 ± (18.77 - 18.83) ms18.89 ± (18.86 - 18.93) ms+0.5%✅⬆️
process.time_to_main_ms67.14 ± (67.03 - 67.25) ms67.27 ± (67.18 - 67.37) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.69 ± (7.69 - 7.70) MB7.70 ± (7.69 - 7.71) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.89 ± (18.87 - 18.92) ms18.80 ± (18.77 - 18.83) ms-0.5%
process.time_to_main_ms68.28 ± (68.21 - 68.34) ms68.25 ± (68.19 - 68.32) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.74 ± (7.74 - 7.75) MB7.72 ± (7.72 - 7.73) MB-0.3%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms177.48 ± (176.59 - 178.37) ms177.69 ± (176.92 - 178.45) ms+0.1%✅⬆️
process.time_to_main_ms428.61 ± (428.06 - 429.17) ms430.35 ± (429.69 - 431.01) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.56 ± (36.54 - 36.59) MB36.60 ± (36.57 - 36.63) MB+0.1%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (26 - 27)-0.4%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration192.79 ± (192.59 - 193.70) ms194.69 ± (194.95 - 196.10) ms+1.0%✅⬆️
.NET Framework 4.8 - Bailout
duration196.52 ± (196.16 - 196.83) ms199.71 ± (199.81 - 200.78) ms+1.6%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1124.09 ± (1128.32 - 1138.01) ms1132.77 ± (1135.53 - 1143.90) ms+0.8%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms188.41 ± (188.05 - 188.76) ms188.97 ± (188.53 - 189.41) ms+0.3%✅⬆️
process.time_to_main_ms80.87 ± (80.67 - 81.06) ms81.65 ± (81.41 - 81.88) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.06 ± (16.04 - 16.09) MB16.18 ± (16.15 - 16.20) MB+0.7%✅⬆️
runtime.dotnet.threads.count20 ± (19 - 20)20 ± (19 - 20)+0.0%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms187.19 ± (186.85 - 187.54) ms190.28 ± (189.83 - 190.72) ms+1.6%✅⬆️
process.time_to_main_ms82.37 ± (82.18 - 82.57) ms83.49 ± (83.27 - 83.72) ms+1.4%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.22 ± (16.19 - 16.25) MB16.13 ± (16.12 - 16.15) MB-0.6%
runtime.dotnet.threads.count21 ± (20 - 21)21 ± (21 - 21)-0.2%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms439.02 ± (436.52 - 441.52) ms429.26 ± (426.29 - 432.23) ms-2.2%
process.time_to_main_ms471.74 ± (471.17 - 472.31) ms481.85 ± (480.69 - 483.01) ms+2.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.57 ± (58.46 - 58.68) MB58.91 ± (58.82 - 59.01) MB+0.6%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 30)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms191.61 ± (191.24 - 191.98) ms194.76 ± (194.29 - 195.24) ms+1.6%✅⬆️
process.time_to_main_ms70.00 ± (69.81 - 70.19) ms71.16 ± (70.94 - 71.38) ms+1.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.05 ± (15.90 - 16.20) MB16.31 ± (16.24 - 16.37) MB+1.6%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)19 ± (19 - 19)+4.3%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms190.60 ± (190.30 - 190.90) ms197.10 ± (196.59 - 197.62) ms+3.4%✅⬆️
process.time_to_main_ms70.94 ± (70.80 - 71.07) ms73.42 ± (73.18 - 73.66) ms+3.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed15.97 ± (15.81 - 16.13) MB16.40 ± (16.38 - 16.42) MB+2.7%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)20 ± (20 - 20)+5.5%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms451.51 ± (448.86 - 454.17) ms442.39 ± (438.54 - 446.25) ms-2.0%
process.time_to_main_ms450.35 ± (449.88 - 450.81) ms457.23 ± (456.51 - 457.94) ms+1.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.65 ± (58.53 - 58.77) MB58.97 ± (58.83 - 59.12) MB+0.5%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms189.63 ± (189.32 - 189.94) ms193.86 ± (193.40 - 194.31) ms+2.2%✅⬆️
process.time_to_main_ms69.77 ± (69.58 - 69.95) ms71.28 ± (71.06 - 71.51) ms+2.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.79 ± (11.76 - 11.82) MB11.71 ± (11.69 - 11.73) MB-0.7%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.5%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms189.03 ± (188.72 - 189.33) ms191.23 ± (190.87 - 191.58) ms+1.2%✅⬆️
process.time_to_main_ms70.85 ± (70.71 - 71.00) ms71.64 ± (71.49 - 71.80) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.81 ± (11.78 - 11.84) MB11.80 ± (11.77 - 11.82) MB-0.1%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.2%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms366.53 ± (365.03 - 368.02) ms368.23 ± (366.57 - 369.89) ms+0.5%✅⬆️
process.time_to_main_ms434.85 ± (434.26 - 435.44) ms437.63 ± (436.91 - 438.36) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed48.13 ± (48.09 - 48.17) MB48.16 ± (48.12 - 48.20) MB+0.0%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-1.1%
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 (8068) - mean (68ms)  : 67, 70
    master - mean (68ms)  : 67, 70

    section Bailout
    This PR (8068) - mean (72ms)  : 71, 73
    master - mean (72ms)  : 71, 73

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (1,020ms)  : 935, 1104
    master - mean (1,008ms)  : 946, 1070

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

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

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (737ms)  : 674, 799
    master - mean (754ms)  : 729, 778

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

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

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (721ms)  : 688, 753
    master - mean (719ms)  : 694, 743

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

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

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (635ms)  : 623, 647
    master - mean (634ms)  : 618, 650

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 (8068) - mean (196ms)  : 188, 203
    master - mean (193ms)  : 187, 199

    section Bailout
    This PR (8068) - mean (200ms)  : 194, 206
    master - mean (196ms)  : 193, 200

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (1,140ms)  : 1080, 1199
    master - mean (1,133ms)  : 1063, 1203

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 (8068) - mean (279ms)  : 273, 285
    master - mean (278ms)  : 271, 284

    section Bailout
    This PR (8068) - mean (283ms)  : 272, 293
    master - mean (277ms)  : 273, 282

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (944ms)  : 903, 984
    master - mean (938ms)  : 904, 973

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8068) - mean (274ms)  : 266, 282
    master - mean (270ms)  : 266, 274

    section Bailout
    This PR (8068) - mean (279ms)  : 269, 288
    master - mean (270ms)  : 266, 274

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (930ms)  : 862, 997
    master - mean (929ms)  : 880, 977

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

    section Bailout
    This PR (8068) - mean (273ms)  : 268, 278
    master - mean (270ms)  : 265, 274

    section CallTarget+Inlining+NGEN
    This PR (8068) - mean (839ms)  : 819, 858
    master - mean (831ms)  : 810, 851

Loading

@datadog-official
Copy link

datadog-official bot commented Jan 15, 2026

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

❄️ 5 New flaky tests detected

TestEndpointsCollection from Datadog.Trace.Security.IntegrationTests.ApiSecurity.AspNetCore5EndpointsEnabledLimited (Datadog) (Fix with Cursor)
Unable to determine port application is listening on
TestVulnerabilityStack from Datadog.Trace.Security.IntegrationTests.Iast.AspNetCore5IastTestsStackTraces (Datadog) (Fix with Cursor)
Results do not match.
Differences:
Received: Iast.Stacks.Vulnerability.InFunction.received.txt
Verified: Iast.Stacks.Vulnerability.InFunction.verified.txt
Compare Result:
- [
+ []
-   {
-     TraceId: Id_1,
-     SpanId: Id_2,
...
TestVulnerabilityStack from Datadog.Trace.Security.IntegrationTests.Iast.AspNetCore5IastTestsStackTraces (Datadog) (Fix with Cursor)
Results do not match.
Differences:
Received: Iast.Stacks.Vulnerability.LocatedInRenderPipeline.received.txt
Verified: Iast.Stacks.Vulnerability.LocatedInRenderPipeline.verified.txt
Compare Result:
- [
+ []
-   {
-     TraceId: Id_1,
-     SpanId: Id_2,
...
View all

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c83799b | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@andrewlock andrewlock merged commit bbf81d6 into master Jan 15, 2026
153 of 154 checks passed
@andrewlock andrewlock deleted the andrew/fix-environment-version branch January 15, 2026 18:13
@github-actions github-actions bot added this to the vNext-v3 milestone Jan 15, 2026
return productVersion;
}

private static bool GetDotNetFrameworkProductMapping(
Copy link
Member

Choose a reason for hiding this comment

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

This could probably also move to FrameworkDescription.NetFramework.cs to exclude the code entirely for other TFMs.

Copy link
Member Author

Choose a reason for hiding this comment

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

So FrameworkDescription.NetFramework is only in .NET Framework, but given the above is needed for .NET Standard 2.0 as well, it's probably correct?

andrewlock added a commit that referenced this pull request Jan 15, 2026
## Summary of changes

Replaced remaining usages of `Environment.Version` other than
`FrameworkDescription`

## Reason for change

`Environment.Version` allocates, but it's used in a bunch of places
unnecessarily. Switching to use `FrameworkDescription.Runtimeversion`
removes those allocations

## Implementation details

- Find everywhere using `Environment.Version` and fix it to not
- Inlined a couple of places where it didn't seem necessary
- Remove an allocating path in `IsCoreClr()`

## Test coverage

Should be covered by existing

## Other details

Stacked on 
- #8068
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:performance Performance, speed, latency, resource usage (CPU, memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants