Skip to content

Add Environment.Version to the banned API list#8524

Merged
andrewlock merged 1 commit into
masterfrom
andrew/dont-use-environment-version
Apr 29, 2026
Merged

Add Environment.Version to the banned API list#8524
andrewlock merged 1 commit into
masterfrom
andrew/dont-use-environment-version

Conversation

@andrewlock

Copy link
Copy Markdown
Member

Summary of changes

Adds Environment.Version to the banned list of APIs

Reason for change

This API allocates a new Version instance every time, which is relatively expensive. We have a "cached" instance of the value (which can't change at runtime) in FrameworkDescription.Instance, so enforce using that instead

Implementation details

  • Add the API to the banned list
  • Add exclusions in FrameworkDescription
  • Fix (single) offending case

Test coverage

As long at the existing tests pass, we're good

@andrewlock
andrewlock requested a review from a team as a code owner April 27, 2026 09:54
@andrewlock andrewlock added the type:performance Performance, speed, latency, resource usage (CPU, memory) label Apr 27, 2026
@andrewlock
andrewlock requested a review from a team as a code owner April 27, 2026 09:54
@pr-commenter

pr-commenter Bot commented Apr 27, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-04-27 10:58:50

Comparing candidate commit 0d6560b in PR branch andrew/dont-use-environment-version with baseline commit a5f6d3d in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics, 62 known flaky benchmarks, 25 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-6025.402op/s; -5612.825op/s] or [-7.144%; -6.655%]

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

  • 🟩 throughput [+8368.996op/s; +10628.898op/s] or [+7.034%; +8.934%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+310.437ms; +315.367ms] or [+154.050%; +156.496%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 execution_time [+385.977ms; +388.223ms] or [+304.946%; +306.720%]

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

  • 🟥 execution_time [+395.575ms; +398.277ms] or [+350.069%; +352.460%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.529%; +27.541%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.977%; +9.987%]
  • 🟩 execution_time [-15.649ms; -11.479ms] or [-7.309%; -5.361%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+27.502%; +27.510%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.746%; +105.759%]
  • 🟥 throughput [-263731.307op/s; -260889.834op/s] or [-26.928%; -26.638%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.558%; +38.566%]
  • 🟩 execution_time [-25.986ms; -21.117ms] or [-11.589%; -9.417%]
  • 🟥 throughput [-97482.988op/s; -73539.792op/s] or [-10.414%; -7.856%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.292%; +105.304%]
  • 🟥 throughput [-144273.018op/s; -127602.123op/s] or [-20.729%; -18.334%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0

  • 🟩 throughput [+8973.470op/s; +11903.064op/s] or [+5.710%; +7.574%]

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

  • 🟩 throughput [+6422.560op/s; +9059.103op/s] or [+5.116%; +7.217%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 throughput [+352189.466op/s; +381373.005op/s] or [+11.744%; +12.717%]

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

  • 🟩 execution_time [-19.282ms; -14.902ms] or [-8.888%; -6.869%]
  • 🟩 throughput [+168889.211op/s; +223307.652op/s] or [+6.704%; +8.864%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟥 execution_time [+299.878ms; +300.436ms] or [+149.839%; +150.118%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟥 execution_time [+300.075ms; +303.472ms] or [+151.328%; +153.042%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟥 execution_time [+300.265ms; +303.024ms] or [+151.250%; +152.640%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+297.791ms; +298.313ms] or [+146.263%; +146.520%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+296.122ms; +298.905ms] or [+144.763%; +146.124%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+300.889ms; +302.611ms] or [+150.384%; +151.244%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0

  • 🟥 execution_time [+36.235µs; +64.884µs] or [+8.311%; +14.881%]
  • 🟥 throughput [-302.183op/s; -176.356op/s] or [-13.138%; -7.667%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟥 execution_time [+25.978µs; +49.617µs] or [+8.293%; +15.840%]
  • 🟥 throughput [-457.737op/s; -258.873op/s] or [-14.269%; -8.070%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+300.030ms; +300.695ms] or [+149.746%; +150.077%]

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

  • unstable execution_time [+374.757ms; +406.474ms] or [+407.189%; +441.651%]
  • 🟩 throughput [+1093.126op/s; +1223.661op/s] or [+8.982%; +10.055%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • unstable execution_time [+302.595ms; +340.915ms] or [+229.757%; +258.853%]
  • 🟩 throughput [+625.793op/s; +826.120op/s] or [+6.058%; +7.997%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+324.859ms; +402.897ms] or [+149.367%; +185.248%]
  • 🟥 throughput [-524.356op/s; -460.571op/s] or [-47.512%; -41.732%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • unstable execution_time [+203.413ms; +336.642ms] or [+86.686%; +143.463%]
  • 🟥 throughput [-745.136op/s; -661.644op/s] or [-49.701%; -44.132%]

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

  • 🟥 execution_time [+337.156ms; +346.567ms] or [+201.658%; +207.287%]
  • 🟥 throughput [-405.893op/s; -370.783op/s] or [-28.262%; -25.817%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1

  • 🟩 throughput [+18.138op/s; +41.283op/s] or [+5.214%; +11.867%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+301.210ms; +302.587ms] or [+151.683%; +152.377%]

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

  • 🟥 execution_time [+301.206ms; +302.329ms] or [+150.935%; +151.498%]

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

  • 🟥 execution_time [+302.503ms; +305.701ms] or [+151.964%; +153.571%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+301.039ms; +302.489ms] or [+151.172%; +151.900%]

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

  • 🟥 execution_time [+296.996ms; +298.551ms] or [+146.851%; +147.620%]

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

  • 🟥 execution_time [+303.146ms; +306.683ms] or [+153.648%; +155.440%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+300.746ms; +302.398ms] or [+150.947%; +151.777%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 execution_time [+299.324ms; +301.268ms] or [+149.186%; +150.155%]
  • 🟩 throughput [+32771.988op/s; +38942.470op/s] or [+6.507%; +7.733%]

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

  • 🟥 execution_time [+300.797ms; +303.844ms] or [+149.644%; +151.160%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟩 execution_time [-15.954ms; -11.584ms] or [-7.419%; -5.387%]
  • 🟩 throughput [+22092.320op/s; +30030.950op/s] or [+6.061%; +8.238%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [+7.848µs; +49.251µs] or [+1.938%; +12.165%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-27.117KB; -27.097KB] or [-9.892%; -9.884%]
  • unstable execution_time [-37.154µs; +15.459µs] or [-7.343%; +3.055%]

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

  • 🟩 allocated_mem [-18.617KB; -18.601KB] or [-6.787%; -6.781%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • unstable execution_time [+7.195µs; +11.441µs] or [+17.008%; +27.044%]
  • 🟥 throughput [-5044.252op/s; -3258.916op/s] or [-21.235%; -13.719%]

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

  • unstable execution_time [-13.169µs; -6.139µs] or [-20.432%; -9.524%]
  • 🟩 throughput [+1446.828op/s; +2902.774op/s] or [+8.877%; +17.809%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+303.534ms; +304.840ms] or [+153.423%; +154.083%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+302.210ms; +304.328ms] or [+153.824%; +154.902%]

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

  • 🟥 execution_time [+299.367ms; +301.731ms] or [+149.870%; +151.054%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0

  • 🟩 throughput [+40936.012op/s; +44763.019op/s] or [+7.748%; +8.473%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+299.781ms; +301.466ms] or [+149.414%; +150.254%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+301.182ms; +302.798ms] or [+151.239%; +152.051%]

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

  • 🟥 execution_time [+304.093ms; +306.723ms] or [+154.216%; +155.550%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+300.236ms; +301.054ms] or [+149.759%; +150.167%]
  • 🟩 throughput [+66063333.758op/s; +66326883.171op/s] or [+48.111%; +48.303%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • unstable execution_time [+379.918ms; +409.633ms] or [+472.496%; +509.451%]
  • 🟩 throughput [+1121.856op/s; +1291.824op/s] or [+8.673%; +9.986%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+299.653ms; +300.623ms] or [+149.460%; +149.944%]
  • 🟩 throughput [+18304014.652op/s; +19244098.652op/s] or [+8.107%; +8.524%]

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

  • 🟩 throughput [+97582.481op/s; +106358.449op/s] or [+9.111%; +9.930%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟩 throughput [+55517.063op/s; +74977.555op/s] or [+6.426%; +8.678%]

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

  • 🟩 throughput [+93852.786op/s; +123293.454op/s] or [+7.264%; +9.543%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1

  • 🟩 throughput [+91862.912op/s; +100166.117op/s] or [+9.123%; +9.948%]

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

  • 🟩 throughput [+52376.331op/s; +56713.051op/s] or [+9.511%; +10.298%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1

  • 🟩 throughput [+27488.308op/s; +37229.122op/s] or [+6.153%; +8.333%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟩 throughput [+72256.474op/s; +89907.821op/s] or [+8.073%; +10.045%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

@andrewlock andrewlock changed the title Add Environment.Version to the banned API list Add Environment.Version to the banned API list Apr 27, 2026
@andrewlock
andrewlock merged commit 958612e into master Apr 29, 2026
144 checks passed
@andrewlock
andrewlock deleted the andrew/dont-use-environment-version branch April 29, 2026 08:24
@github-actions github-actions Bot added this to the vNext-v3 milestone Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tools type:performance Performance, speed, latency, resource usage (CPU, memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants