Skip to content

Optimise OTEL metrics collection to reduce allocations#8834

Merged
andrewlock merged 5 commits into
masterfrom
andrew/optimize-tag-set
Jul 2, 2026
Merged

Optimise OTEL metrics collection to reduce allocations#8834
andrewlock merged 5 commits into
masterfrom
andrew/optimize-tag-set

Conversation

@andrewlock

Copy link
Copy Markdown
Member

Summary of changes

Improve the performance of OTEL metrics collection

Reason for change

We need to add constraints to the cardinality of OTEL metrics collection. As part of that work, noticed some easy performance wins:

  • Don't allocate a closure for every call to GetOrCreatePoint()
  • Don't allocate a big string as the tags key - we can use a simple hash instead

As this is all .NET 6+, we can use the more efficient APIs without worrying about earlier TFMs for a change 🎉

Implementation details

  • Use the overload of ConcurrentDictionary<> that takes a state parameter to eliminate the closure
  • Remove TagSet, and instead use a ulong hash as the key
    • This removes the need for building up a large string using StringBuilder
  • Hash the UTF-16 string bytes directly using our FNV hash type
    • If the hash matters, then we should transcode to UTF-8 first, but in this case we don't care, so doing the transcode seems unecessary
    • The main difference is that not transcoding increases the number of bytes we need to loop over by 2x for the common ASCII case, which has a CPU impact on large strings. However, because we don't need to allocate a byte[] for the transcode any more, it reduces allocations in those larger cases too. And for smaller tags the increase in CPU time is negligible

Test coverage

This is just a perf improvement, so tests should be unchanged. Wrote a small benchmark to validate the changes. The following are the .NET 6.0 results, .NET 10 was similar.

Method TagCount TagValueLength Mean Allocated
StringKey 1 8 21.500 ns 56 B
Hash 1 8 29.903 ns -
StringKey 1 100 31.535 ns 240 B
Hash 1 100 182.657 ns -
StringKey 2 8 67.829 ns 144 B
Hash 2 8 94.205 ns 64 B
StringKey 2 100 93.828 ns 512 B
Hash 2 100 403.316 ns 64 B
StringKey 7 8 136.478 ns 296 B
Hash 7 8 264.297 ns 64 B
StringKey 7 100 400.982 ns 4680 B
Hash 7 100 1,336.384 ns 64 B
StringKey 30 8 1,433.900 ns 2608 B
Hash 30 8 1,915.540 ns 64 B
StringKey 30 100 2,568.430 ns 18424 B
Hash 30 100 6,513.963 ns 64 B

Given we're talking about a 4us worst case slow down for 30x100 char tags, but with a redution in 18KB allocation, I think this is preferable

Benchmark Details

// <copyright file="MetricTagsHashBenchmark.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

#if NET6_0_OR_GREATER

#nullable enable

using System;
using System.Buffers;
using System.Collections.Generic;
using System.Globalization;
using BenchmarkDotNet.Attributes;
using Datadog.Trace.OpenTelemetry.Metrics;
using Datadog.Trace.Util;

namespace Benchmarks.Trace;

/// <summary>
/// Compares three ways of deriving the unique-stream key for a set of metric attributes (tags),
/// across a range of tag collection sizes and tag value lengths:
/// <list type="bullet">
/// <item><see cref="StringKey"/> — the original approach: build a string key with a pooled StringBuilder (allocates a string per call).</item>
/// <item><see cref="Utf8Encoding"/> — the first hash-based approach: transcode each key/value to UTF-8, then FNV hash.</item>
/// <item><see cref="CharBytes"/> — the current <see cref="MetricTagsHash.Compute"/>: FNV hash the raw UTF-16 char bytes directly.</item>
/// </list>
/// </summary>
[MemoryDiagnoser]
[BenchmarkCategory(Constants.TracerCategory, Constants.RunOnPrs, Constants.RunOnMaster)]
public class MetricTagsHashBenchmark
{
    private const FnvHash64.Version HashVersion = FnvHash64.Version.V1A;
    private const string PairSeparator = ";";
    private const string KeyValueSeparator = "=";

    private static readonly IComparer<KeyValuePair<string, object?>> KeyComparer =
        Comparer<KeyValuePair<string, object?>>.Create(static (a, b) => string.CompareOrdinal(a.Key, b.Key));

    private KeyValuePair<string, object?>[] _tags = Array.Empty<KeyValuePair<string, object?>>();

    // Number of tags in the collection. Includes the common small cases plus a larger one.
    [Params(0, 1, 2, 7, 30)]
    public int TagCount { get; set; }

    // Length of each tag value. 8 fits the formatting stack buffer comfortably; 100 exceeds the
    // 256-byte stack limit in the UTF-8 path, forcing it to allocate on the heap.
    [Params(8, 100)]
    public int ValueLength { get; set; }

    [GlobalSetup]
    public void Setup()
    {
        _tags = new KeyValuePair<string, object?>[TagCount];
        for (var i = 0; i < TagCount; i++)
        {
            // Deterministic-but-varied keys/values so sorting and hashing do real work.
            var key = "tag." + i.ToString(CultureInfo.InvariantCulture);
            var value = new string((char)('a' + (i % 26)), ValueLength);
            _tags[i] = new KeyValuePair<string, object?>(key, value);
        }
    }

    [Benchmark(Baseline = true)]
    public string StringKey() => ComputeStringKey(_tags);

    [Benchmark]
    public ulong Utf8Encoding() => ComputeUtf8(_tags);

    [Benchmark]
    public ulong CharBytes() => MetricTagsHash.Compute(_tags);

    // ---- Previous implementation: transcodes each segment to UTF-8 before hashing ----

    private static ulong ComputeUtf8(ReadOnlySpan<KeyValuePair<string, object?>> tags)
    {
        var hash = FnvHash64.GenerateHash(string.Empty, HashVersion);

        var len = tags.Length;
        if (len == 0)
        {
            return hash;
        }

        if (len == 1)
        {
            return HashPairUtf8(tags[0], hash);
        }

        var sorted = ArrayPool<KeyValuePair<string, object?>>.Shared.Rent(len);
        try
        {
            tags.CopyTo(sorted);
            Array.Sort(sorted, 0, len, KeyComparer);

            for (var i = 0; i < len; i++)
            {
                if (i > 0)
                {
                    hash = FnvHash64.GenerateHash(PairSeparator, HashVersion, hash);
                }

                hash = HashPairUtf8(sorted[i], hash);
            }

            return hash;
        }
        finally
        {
            ArrayPool<KeyValuePair<string, object?>>.Shared.Return(sorted);
        }
    }

    [System.Runtime.CompilerServices.SkipLocalsInit]
    private static ulong HashPairUtf8(KeyValuePair<string, object?> tag, ulong hash)
    {
        hash = FnvHash64.GenerateHash(tag.Key, HashVersion, hash);
        hash = FnvHash64.GenerateHash(KeyValueSeparator, HashVersion, hash);
        if (tag.Value is null)
        {
            return hash;
        }

        if (tag.Value is ISpanFormattable spanFormattable)
        {
            Span<char> buffer = stackalloc char[128];

            if (spanFormattable.TryFormat(buffer, out var written, format: default, provider: CultureInfo.InvariantCulture))
            {
                return FnvHash64.GenerateHash(buffer.Slice(0, written), HashVersion, hash);
            }
        }

        var stringValue = tag.Value is IFormattable formattable
                              ? formattable.ToString(format: null, CultureInfo.InvariantCulture)
                              : tag.Value.ToString();

        return string.IsNullOrEmpty(stringValue)
                   ? hash
                   : FnvHash64.GenerateHash(stringValue, HashVersion, hash);
    }

    // ---- Original implementation: builds a string key via a pooled StringBuilder ----
    // Replicates the removed TagSet.FromSpan; the returned string was used directly as the dictionary key.

    private static string ComputeStringKey(ReadOnlySpan<KeyValuePair<string, object?>> tags)
    {
        var len = tags.Length;
        if (len == 0)
        {
            return string.Empty;
        }

        if (len == 1)
        {
            var kv = tags[0];
            var single = StringBuilderCache.Acquire();
            single.Append(kv.Key).Append('=');
            if (kv.Value is not null)
            {
                single.Append(kv.Value);
            }

            return StringBuilderCache.GetStringAndRelease(single);
        }

        var sorted = ArrayPool<KeyValuePair<string, object?>>.Shared.Rent(len);
        try
        {
            tags.CopyTo(sorted);
            Array.Sort(sorted, 0, len, KeyComparer);

            var sb = StringBuilderCache.Acquire();
            for (var i = 0; i < len; i++)
            {
                if (i > 0)
                {
                    sb.Append(';');
                }

                var kv = sorted[i];
                sb.Append(kv.Key).Append('=');
                if (kv.Value is not null)
                {
                    sb.Append(kv.Value);
                }
            }

            return StringBuilderCache.GetStringAndRelease(sb);
        }
        finally
        {
            ArrayPool<KeyValuePair<string, object?>>.Shared.Return(sorted);
        }
    }
}

#endif

Other details

Prereq for cardinality limiting of OTel metrics

@andrewlock
andrewlock requested a review from a team as a code owner June 26, 2026 10:36
@andrewlock andrewlock added 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) area:opentelemetry OpenTelemetry support labels Jun 26, 2026
@andrewlock andrewlock changed the title Optimise OTEL metrics collection Optimise OTEL metrics collection to reduce allocations Jun 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6127818c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +89 to +91
if (spanFormattable.TryFormat(buffer, out var written, format: default, provider: CultureInfo.InvariantCulture))
{
return HashChars(buffer.Slice(0, written), hash);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep tag hashing consistent with exported values

When the process runs under a culture whose numeric formatting differs from invariant culture, this makes semantically different exported tag values share one MetricPoint. For example, with CurrentCulture = de-DE, a tag value 3.14d hashes as "3.14" here, so it collides with the string tag "3.14"; however OtlpMetricsSerializer still exports metric tags with tag.Value?.ToString(), so the double would be emitted as "3,14" while the string is emitted as "3.14". Because MetricState now keys only by this hash and keeps the first tag dictionary, one of those time series is aggregated under the other's attributes instead of producing a separate data point.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@zacharycmontoya @link04 I explicitly switched to using culture-invariant exporting here - I'm wondering if we should do the same in OtlpMetricsSerializer, or whether we should keep the culture-dependant behaviour instead? WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the choice to do culture-invariant is fine for now. Eventually, we should mimic the behavior of opentelemetry-dotnet to emit tags that keep their original primitive type (a tag with an integer value is emitted as an OTLPIntValue) but for now we just need to be consistent between this key cache and the emitted key output.

Comment thread tracer/src/Datadog.Trace/Util/FnvHash64.cs Outdated
Comment on lines +121 to +123
var hash = MetricTagsHash.Compute(tags);

if (_points.TryGetValue(tagSet, out var existingPoint))
if (_points.TryGetValue(hash, out var existingPoint))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve hash collisions before reusing metric points

When two different metric attribute sets produce the same 64-bit FNV value, this lookup reuses the existing MetricPoint without comparing the actual tags, so subsequent measurements are aggregated under the first point's tag dictionary and the other time series is never exported separately. Because metric attribute keys and values can be arbitrary application strings, keep enough tag identity to disambiguate collisions (for example a collision bucket or equality check) instead of treating the hash as the sole identity.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought about this before, but wasn't sure if it was necessary tbh? 🤔 The chances of collisions are very low. With 2000 metric point, the chance of collision is ~1 in 9 trillion 😅 It doesn't seem worth worrying about that to me

@andrewlock
andrewlock force-pushed the andrew/optimize-tag-set branch from b612781 to 36baa14 Compare June 26, 2026 11:19
@pr-commenter

pr-commenter Bot commented Jun 26, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-01 10:15:51

Comparing candidate commit c5646d2 in PR branch andrew/optimize-tag-set with baseline commit 950b9d5 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 72 metrics, 0 unstable metrics, 62 known flaky benchmarks, 64 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.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net6.0

  • 🟥 throughput [-18117.999op/s; -15884.199op/s] or [-6.515%; -5.712%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-7226.592op/s; -6776.921op/s] or [-8.569%; -8.035%]

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

  • 🟥 throughput [-9135.963op/s; -6722.695op/s] or [-9.289%; -6.835%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+301.681ms; +308.585ms] or [+149.705%; +153.131%]
  • 🟥 throughput [-46.016op/s; -42.413op/s] or [-8.279%; -7.631%]

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

  • 🟥 execution_time [+384.317ms; +386.542ms] or [+303.634%; +305.392%]
  • 🟩 throughput [+87.993op/s; +95.143op/s] or [+11.602%; +12.544%]

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

  • 🟥 execution_time [+394.840ms; +399.440ms] or [+349.418%; +353.489%]

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

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.528%; +27.540%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.976%; +9.987%]

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

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

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

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.743%; +105.758%]
  • 🟥 throughput [-267708.038op/s; -264365.268op/s] or [-27.334%; -26.993%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.557%; +38.566%]
  • 🟩 execution_time [-26.103ms; -21.243ms] or [-11.641%; -9.473%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.288%; +105.304%]
  • 🟥 throughput [-155308.338op/s; -139092.721op/s] or [-22.315%; -19.985%]

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

  • 🟩 throughput [+8693.161op/s; +11707.776op/s] or [+5.531%; +7.449%]

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

  • 🟩 throughput [+9412.039op/s; +12083.861op/s] or [+7.498%; +9.626%]

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

  • 🟩 throughput [+502880.991op/s; +524490.437op/s] or [+16.768%; +17.489%]

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

  • 🟩 execution_time [-19.083ms; -14.753ms] or [-8.797%; -6.800%]
  • 🟩 throughput [+173739.675op/s; +227537.585op/s] or [+6.896%; +9.032%]

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

  • 🟥 execution_time [+299.153ms; +300.039ms] or [+149.477%; +149.919%]

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

  • 🟥 execution_time [+300.750ms; +304.180ms] or [+151.669%; +153.398%]

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

  • 🟥 execution_time [+300.141ms; +302.608ms] or [+151.188%; +152.430%]

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

  • 🟥 execution_time [+296.803ms; +297.956ms] or [+145.778%; +146.344%]

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

  • 🟥 execution_time [+294.406ms; +297.670ms] or [+143.924%; +145.520%]

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

  • 🟥 execution_time [+300.549ms; +303.207ms] or [+150.214%; +151.542%]

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

  • 🟥 execution_time [+20.697µs; +44.340µs] or [+6.608%; +14.155%]
  • 🟥 throughput [-414.695op/s; -215.741op/s] or [-12.927%; -6.725%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.690ms; +300.496ms] or [+149.576%; +149.978%]

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

  • unstable execution_time [+342.904ms; +402.405ms] or [+372.580%; +437.230%]
  • 🟩 throughput [+699.611op/s; +884.609op/s] or [+5.749%; +7.269%]

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

  • unstable execution_time [+297.794ms; +350.306ms] or [+226.112%; +265.984%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 allocated_mem [+2.824KB; +2.829KB] or [+5.017%; +5.026%]
  • unstable execution_time [+363.898ms; +419.397ms] or [+167.317%; +192.835%]
  • 🟥 throughput [-559.058op/s; -508.422op/s] or [-50.656%; -46.068%]

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

  • unstable execution_time [+208.391ms; +341.624ms] or [+88.807%; +145.586%]
  • 🟥 throughput [-674.608op/s; -590.989op/s] or [-44.997%; -39.419%]

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

  • 🟥 execution_time [+313.484ms; +327.006ms] or [+187.500%; +195.588%]
  • 🟥 throughput [-397.291op/s; -359.097op/s] or [-27.663%; -25.003%]

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

  • unstable execution_time [-203.218µs; -6.381µs] or [-10.887%; -0.342%]
  • unstable throughput [+13.574op/s; +139.581op/s] or [+2.534%; +26.054%]

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

  • 🟩 execution_time [-188.897µs; -172.148µs] or [-9.569%; -8.720%]
  • 🟩 throughput [+48.588op/s; +53.679op/s] or [+9.592%; +10.597%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+301.487ms; +303.114ms] or [+151.823%; +152.643%]

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

  • 🟥 execution_time [+301.854ms; +304.852ms] or [+151.260%; +152.762%]
  • 🟩 throughput [+39071.086op/s; +44610.104op/s] or [+6.160%; +7.033%]

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

  • 🟥 execution_time [+300.984ms; +304.149ms] or [+151.202%; +152.791%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+300.954ms; +302.215ms] or [+151.129%; +151.762%]

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

  • 🟥 execution_time [+298.992ms; +301.615ms] or [+147.838%; +149.135%]

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

  • 🟥 execution_time [+304.132ms; +308.044ms] or [+154.148%; +156.130%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+299.792ms; +301.955ms] or [+150.468%; +151.554%]

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

  • 🟥 execution_time [+301.613ms; +303.749ms] or [+150.327%; +151.391%]
  • 🟩 throughput [+42461.773op/s; +50576.630op/s] or [+8.432%; +10.043%]

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

  • 🟥 execution_time [+300.814ms; +303.389ms] or [+149.652%; +150.933%]

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

  • 🟩 execution_time [-16.147ms; -12.503ms] or [-7.508%; -5.814%]

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

  • unstable execution_time [+14.151µs; +64.168µs] or [+3.495%; +15.850%]

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

  • 🟩 allocated_mem [-20.443KB; -20.421KB] or [-7.457%; -7.449%]
  • unstable execution_time [-40.164µs; +20.139µs] or [-7.938%; +3.980%]
  • unstable throughput [-60.899op/s; +150.426op/s] or [-3.039%; +7.506%]

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

  • unstable execution_time [+47.770µs; +237.917µs] or [+8.278%; +41.229%]
  • unstable throughput [-303.037op/s; -10.598op/s] or [-17.313%; -0.605%]

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

  • unstable execution_time [+7.707µs; +12.428µs] or [+18.216%; +29.376%]
  • 🟥 throughput [-5420.689op/s; -3490.506op/s] or [-22.819%; -14.694%]

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

  • unstable execution_time [-14.250µs; -6.536µs] or [-22.109%; -10.140%]
  • unstable throughput [+1630.141op/s; +3297.165op/s] or [+10.001%; +20.229%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+303.354ms; +304.859ms] or [+153.332%; +154.093%]

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

  • 🟥 execution_time [+301.976ms; +304.602ms] or [+153.705%; +155.041%]

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

  • 🟥 execution_time [+301.684ms; +304.478ms] or [+151.030%; +152.429%]

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

  • 🟩 throughput [+32356.005op/s; +35726.830op/s] or [+6.124%; +6.762%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+301.075ms; +303.764ms] or [+150.059%; +151.399%]

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

  • 🟥 execution_time [+302.718ms; +305.183ms] or [+152.010%; +153.248%]

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

  • 🟥 execution_time [+303.171ms; +305.430ms] or [+153.749%; +154.895%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+300.689ms; +301.559ms] or [+149.985%; +150.419%]
  • 🟩 throughput [+61105964.278op/s; +61409423.641op/s] or [+44.501%; +44.722%]

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

  • unstable execution_time [+326.870ms; +396.634ms] or [+406.521%; +493.284%]

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

  • 🟥 execution_time [+299.622ms; +300.852ms] or [+149.444%; +150.058%]

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

  • 🟩 throughput [+79118.419op/s; +90715.475op/s] or [+7.387%; +8.470%]

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

  • 🟩 throughput [+52929.227op/s; +71935.052op/s] or [+6.126%; +8.326%]

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

  • 🟩 throughput [+79947.862op/s; +110749.469op/s] or [+6.188%; +8.572%]

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

  • 🟩 throughput [+72040.712op/s; +82535.318op/s] or [+7.155%; +8.197%]

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

  • 🟩 throughput [+48783.745op/s; +53598.433op/s] or [+8.858%; +9.733%]

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

  • 🟩 throughput [+83946.661op/s; +101566.913op/s] or [+9.379%; +11.348%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • 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 net6.0
  • 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.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • 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.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8834) 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
duration69.65 ± (69.79 - 70.14) ms72.66 ± (72.38 - 72.88) ms+4.3%✅⬆️
.NET Framework 4.8 - Bailout
duration73.78 ± (73.68 - 73.94) ms75.38 ± (75.46 - 75.92) ms+2.2%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1079.59 ± (1080.80 - 1089.35) ms1075.39 ± (1075.93 - 1082.43) ms-0.4%
.NET Core 3.1 - Baseline
process.internal_duration_ms22.07 ± (22.03 - 22.11) ms22.38 ± (22.32 - 22.43) ms+1.4%✅⬆️
process.time_to_main_ms80.67 ± (80.46 - 80.87) ms82.99 ± (82.70 - 83.29) ms+2.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.91 - 10.92) MB10.93 ± (10.92 - 10.93) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.07 ± (22.04 - 22.11) ms22.06 ± (22.04 - 22.09) ms-0.1%
process.time_to_main_ms81.78 ± (81.65 - 81.91) ms82.55 ± (82.36 - 82.74) ms+0.9%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.95 - 10.96) MB10.96 ± (10.96 - 10.97) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms210.62 ± (209.62 - 211.62) ms209.40 ± (208.64 - 210.15) ms-0.6%
process.time_to_main_ms533.87 ± (532.52 - 535.22) ms529.17 ± (528.22 - 530.13) ms-0.9%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.73 ± (48.70 - 48.76) MB48.76 ± (48.73 - 48.79) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.3%
.NET 6 - Baseline
process.internal_duration_ms20.84 ± (20.82 - 20.87) ms20.92 ± (20.89 - 20.95) ms+0.4%✅⬆️
process.time_to_main_ms69.79 ± (69.66 - 69.92) ms69.93 ± (69.79 - 70.07) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.63 ± (10.63 - 10.63) MB10.65 ± (10.65 - 10.65) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.71 ± (20.68 - 20.75) ms21.15 ± (21.10 - 21.20) ms+2.1%✅⬆️
process.time_to_main_ms70.45 ± (70.36 - 70.54) ms72.81 ± (72.56 - 73.06) ms+3.4%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.74 ± (10.74 - 10.74) MB10.76 ± (10.76 - 10.76) MB+0.2%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms372.15 ± (370.02 - 374.27) ms373.08 ± (370.94 - 375.21) ms+0.2%✅⬆️
process.time_to_main_ms536.46 ± (535.37 - 537.56) ms535.34 ± (534.06 - 536.62) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed50.12 ± (50.10 - 50.15) MB50.21 ± (50.19 - 50.23) MB+0.2%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms19.37 ± (19.33 - 19.41) ms19.15 ± (19.12 - 19.19) ms-1.1%
process.time_to_main_ms71.33 ± (71.07 - 71.59) ms69.25 ± (69.05 - 69.45) ms-2.9%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.69 ± (7.68 - 7.70) MB7.67 ± (7.67 - 7.68) MB-0.2%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.18 ± (19.15 - 19.21) ms19.02 ± (18.98 - 19.05) ms-0.8%
process.time_to_main_ms71.27 ± (71.09 - 71.44) ms69.83 ± (69.71 - 69.94) ms-2.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.73 ± (7.72 - 7.73) MB7.74 ± (7.73 - 7.74) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms297.76 ± (295.76 - 299.75) ms297.84 ± (295.62 - 300.06) ms+0.0%✅⬆️
process.time_to_main_ms482.99 ± (482.10 - 483.89) ms485.61 ± (484.58 - 486.64) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed37.10 ± (37.07 - 37.12) MB37.22 ± (37.19 - 37.25) MB+0.3%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.1%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration202.13 ± (201.57 - 202.41) ms200.55 ± (200.16 - 201.08) ms-0.8%
.NET Framework 4.8 - Bailout
duration206.69 ± (206.17 - 206.97) ms203.77 ± (203.24 - 203.86) ms-1.4%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1202.85 ± (1203.15 - 1209.61) ms1196.68 ± (1196.60 - 1202.59) ms-0.5%
.NET Core 3.1 - Baseline
process.internal_duration_ms194.73 ± (194.29 - 195.18) ms194.99 ± (194.52 - 195.47) ms+0.1%✅⬆️
process.time_to_main_ms84.79 ± (84.52 - 85.07) ms84.67 ± (84.44 - 84.90) ms-0.1%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.04 ± (16.01 - 16.07) MB16.02 ± (15.99 - 16.05) MB-0.1%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-1.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms194.02 ± (193.68 - 194.36) ms194.78 ± (194.42 - 195.14) ms+0.4%✅⬆️
process.time_to_main_ms86.11 ± (85.90 - 86.33) ms86.03 ± (85.81 - 86.25) ms-0.1%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.07 ± (16.05 - 16.10) MB16.05 ± (16.02 - 16.08) MB-0.1%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)-0.2%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms386.87 ± (385.53 - 388.20) ms388.05 ± (386.66 - 389.45) ms+0.3%✅⬆️
process.time_to_main_ms542.08 ± (541.06 - 543.10) ms543.29 ± (542.13 - 544.44) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed57.95 ± (57.74 - 58.16) MB58.07 ± (57.87 - 58.27) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.2%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms199.91 ± (199.46 - 200.37) ms200.05 ± (199.60 - 200.50) ms+0.1%✅⬆️
process.time_to_main_ms73.68 ± (73.44 - 73.92) ms73.63 ± (73.32 - 73.94) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.39 ± (16.36 - 16.42) MB16.42 ± (16.39 - 16.44) MB+0.2%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-1.4%
.NET 6 - Bailout
process.internal_duration_ms198.98 ± (198.59 - 199.36) ms198.59 ± (198.26 - 198.91) ms-0.2%
process.time_to_main_ms74.69 ± (74.48 - 74.91) ms74.79 ± (74.60 - 74.98) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.45 ± (16.42 - 16.47) MB16.54 ± (16.52 - 16.57) MB+0.6%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.1%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms583.99 ± (581.50 - 586.49) ms586.48 ± (584.08 - 588.89) ms+0.4%✅⬆️
process.time_to_main_ms548.43 ± (547.39 - 549.47) ms551.78 ± (550.56 - 552.99) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed61.30 ± (61.22 - 61.38) MB61.39 ± (61.27 - 61.50) MB+0.1%✅⬆️
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)-0.3%
.NET 8 - Baseline
process.internal_duration_ms196.90 ± (196.43 - 197.38) ms197.86 ± (197.46 - 198.26) ms+0.5%✅⬆️
process.time_to_main_ms72.98 ± (72.69 - 73.26) ms73.48 ± (73.19 - 73.76) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.77 ± (11.74 - 11.79) MB11.69 ± (11.66 - 11.71) MB-0.7%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 19)+0.7%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms196.43 ± (196.07 - 196.80) ms197.01 ± (196.57 - 197.45) ms+0.3%✅⬆️
process.time_to_main_ms74.00 ± (73.81 - 74.20) ms74.41 ± (74.21 - 74.61) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.81 ± (11.80 - 11.83) MB11.72 ± (11.70 - 11.74) MB-0.8%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.3%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms510.96 ± (508.49 - 513.42) ms511.92 ± (508.88 - 514.96) ms+0.2%✅⬆️
process.time_to_main_ms496.00 ± (495.11 - 496.88) ms501.84 ± (501.02 - 502.66) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed50.99 ± (50.96 - 51.02) MB50.89 ± (50.85 - 50.93) MB-0.2%
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (30 - 30)+0.6%✅⬆️
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 (8834) - mean (73ms)  : 69, 76
    master - mean (70ms)  : 67, 73

    section Bailout
    This PR (8834) - mean (76ms)  : 72, 79
    master - mean (74ms)  : 73, 75

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (1,079ms)  : 1031, 1128
    master - mean (1,085ms)  : 1022, 1148

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 (8834) - mean (113ms)  : 106, 119
    master - mean (109ms)  : 105, 113

    section Bailout
    This PR (8834) - mean (111ms)  : 108, 114
    master - mean (110ms)  : 108, 112

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (775ms)  : 748, 803
    master - mean (780ms)  : 760, 801

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

    section Bailout
    This PR (8834) - mean (101ms)  : 96, 106
    master - mean (97ms)  : 96, 99

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (939ms)  : 895, 982
    master - mean (938ms)  : 902, 974

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

    section Bailout
    This PR (8834) - mean (95ms)  : 93, 97
    master - mean (97ms)  : 94, 101

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (812ms)  : 772, 852
    master - mean (813ms)  : 776, 850

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 (8834) - mean (201ms)  : 196, 205
    master - mean (202ms)  : 197, 207

    section Bailout
    This PR (8834) - mean (204ms)  : 201, 207
    master - mean (207ms)  : 203, 210

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (1,200ms)  : 1156, 1243
    master - mean (1,206ms)  : 1160, 1253

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 (8834) - mean (289ms)  : 283, 294
    master - mean (290ms)  : 283, 297

    section Bailout
    This PR (8834) - mean (289ms)  : 285, 294
    master - mean (290ms)  : 285, 294

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (972ms)  : 948, 997
    master - mean (969ms)  : 950, 989

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8834) - mean (283ms)  : 277, 290
    master - mean (283ms)  : 276, 290

    section Bailout
    This PR (8834) - mean (283ms)  : 278, 288
    master - mean (283ms)  : 279, 288

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (1,173ms)  : 1133, 1214
    master - mean (1,163ms)  : 1129, 1196

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8834) - mean (282ms)  : 275, 290
    master - mean (280ms)  : 275, 286

    section Bailout
    This PR (8834) - mean (282ms)  : 277, 288
    master - mean (281ms)  : 275, 286

    section CallTarget+Inlining+NGEN
    This PR (8834) - mean (1,046ms)  : 1000, 1091
    master - mean (1,038ms)  : 998, 1078

Loading

@zacharycmontoya zacharycmontoya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, though I've noted an improvement that we need to make at a later time when emitting attributes on OTLP metrics

@andrewlock
andrewlock force-pushed the andrew/optimize-tag-set branch from 36baa14 to 1bfb0cb Compare July 1, 2026 09:20
@andrewlock
andrewlock merged commit e5a5082 into master Jul 2, 2026
140 checks passed
@andrewlock
andrewlock deleted the andrew/optimize-tag-set branch July 2, 2026 13:02
@github-actions github-actions Bot added this to the vNext-v3 milestone Jul 2, 2026
andrewlock added a commit that referenced this pull request Jul 2, 2026
## Summary of changes

Add configuration for controlling cardinality of OTEL metrics

## Reason for change

Currently we have unbounded cardinality of OTEL metrics collected using
the `System.Diagnostics.Metrics` namespace. However, this can have
implications for memory use, and in accordance [to the
spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#cardinality-limits),
this PR adds a default 200 point limit, which can be overridden by
`DD_METRICS_OTEL_MAX_CARDINALITY`.

## Implementation details

- Add `DD_METRICS_OTEL_MAX_CARDINALITY` with a default value of 2000
- Limit the maximum cardinality of points per-meter
- Additional points received after exceeding the limit are stored in an
[overflow
point](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#overflow-attribute)
- The cardinality is for the lifetime of the app; it doesn't reset each
flush period

## Test coverage

Added a bunch of unit tests to demonstrate the behaviour

## Other details

Designed to be used in conjunction with 
- #8834

Addresses 
- https://datadoghq.atlassian.net/browse/APMSP-3500
- https://datadoghq.atlassian.net/browse/APMSP-3503

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:opentelemetry OpenTelemetry support 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.

2 participants