Skip to content

[feature request] Opt-in granular GC pause duration per generation in OpenTelemetry.Instrumentation.Runtime #3977

Closed as duplicate

Description

@AguirreMoy

Component

OpenTelemetry.Instrumentation.Runtime

Is your feature request related to a problem?

Currently, OpenTelemetry.Instrumentation.Runtime exposes the process.runtime.dotnet.gc.duration metric, which tracks the cumulative GC pause time across the lifetime of the application. While useful for high-level monitoring, it lacks the granularity needed for deep performance tuning. When an application experiences GC-induced latency spikes, knowing the total pause time isn't enough to determine if the culprit is frequent Gen 0 collections or expensive blocking Gen 2 / LOH collections.

What is the expected behavior?

I would like to propose adding an optional, opt-in configuration to OpenTelemetry.Instrumentation.Runtime that captures GC pause duration broken down by generation.

GC.GetTotalPauseDuration() does not expose generation tags, I understand this would likely require an internal EventListener hooked into the Microsoft-Windows-DotNETRuntime provider (tracking GCSuspendEEBegin, GCRestartEEEnd, and GCStart events).

Given the potential overhead of EventListener, this feature would be strictly opt-in via RuntimeMetricsOptions.

options.EnableGenerationAwareGcPauseDuration = true

This would allow users to slice their telemetry by attributes like:

  • generation: gen0, gen1, gen2
  • gc_type: blocking, background

Which alternative solutions or features have you considered?

  • Relying solely on gc.collections.count: We currently have collection counts by generation, but a high Gen 0 count doesn't necessarily mean high pause times.
  • Custom EventListener: Users can write their own custom EventListener to track this and export it to OpenTelemetry, but GC pause time by generation is a runtime metric that would greatly benefit the wider ecosystem if included in the official contrib package.

Additional context

As a disabled by default option, I'd love to hear the maintainers' thoughts on whether this architectural tradeoff is acceptable for an opt-in feature.

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Activity

  1. changed the title [-][feature request] OpenTelemetry.Instrumentation.Runtime[/-] [+][feature request] Opt-in granular GC pause duration per generation in OpenTelemetry.Instrumentation.Runtime[/+] on Mar 18, 2026
  2. Kielek commented on Mar 19, 2026

    @Kielek
    Member

    I think that this request better suits dotnet/runtime repository. For .NET9+ this package is only listening on the natively provided data: https://learn.microsoft.com/en-us/dotnet/core/diagnostics/built-in-metrics-runtime

    If possible, we should not-introduce features into the older frameworks if we are not able to provide them in the newest.

    BTW What is your .NET (Framework) version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions