Skip to content

Consider providing histogram buckets for metrics #467

@danielmarbach

Description

@danielmarbach

Describe the suggested improvement

Asp.net metrics support histogram bucket advice. This is currently not supported in the .NET Histograms.

        _eventDuration = _meter.CreateHistogram(
            "aspnetcore.components.handle_event.duration",
            unit: "s",
            description: "Duration of processing browser event.  It includes business logic of the component but not affected child components.",
            advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = MetricsConstants.ShortSecondsBucketBoundaries });

Once they are it might make sense to consider adding bucket advice and ways to override the defaulfts.

internal static class TransactionalSessionMetricsConstants
{
    // For commit and dispatch operations - typically fast operations measured in milliseconds to low seconds
    // Based on NServiceBus domain knowledge of typical transaction commit times
    public static readonly IReadOnlyList<double> OperationDurationSecondsBuckets = 
        [0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30];

    // For message transit time - can vary widely based on infrastructure and load
    // Covers milliseconds to hours for various message queuing scenarios
    public static readonly IReadOnlyList<double> TransitTimeSecondsBuckets = 
        [0.001, 0.01, 0.1, 0.5, 1, 5, 10, 30, 60, 300, 600, 1800, 3600, 7200];

    // For retry attempts - discrete values, most messages succeed on first attempt
    // Covers typical retry patterns in messaging systems
    public static readonly IReadOnlyList<double> AttemptCountBuckets = 
        [1, 2, 3, 4, 5, 10, 20, 50];
}

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions