Skip to content

The given key '8' was not present in the dictionary exception #69

@oionut

Description

@oionut

Hi
I'm facing an exception thrown by the ThreadPoolMetricsProducer:

System.Collections.Generic.KeyNotFoundException: The given key '8' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Prometheus.DotNetRuntime.Metrics.Producers.ThreadPoolMetricsProducer.<RegisterMetrics>b__29_4(ThreadPoolAdjustedEvent e)
   at Prometheus.DotNetRuntime.EventListening.DotNetEventListener.OnEventWritten(EventWrittenEventArgs eventData)

This happens on a dotnet 6 web api application using the prometheus-net.DotNetRuntime version 4.2.3.
The way the collector is initialized:

...
var builder = DotNetRuntimeStatsBuilder.Default();

if (!_options.UseDefaultMetrics)
{
    builder = DotNetRuntimeStatsBuilder.Customize()
        .WithContentionStats(CaptureLevel.Informational)
        .WithGcStats(CaptureLevel.Verbose)
        .WithThreadPoolStats(CaptureLevel.Informational)
        .WithExceptionStats(CaptureLevel.Errors)
        .WithJitStats();
}

builder
    .RecycleCollectorsEvery(_options.RecycleEvery)
    .WithErrorHandler(ex => _logger.LogError(ex, "Unexpected exception occurred in prometheus-net.DotNetRuntime"));

if (_options.UseDebuggingMetrics)
{
    _logger.LogInformation("Using debugging metrics.");
    builder.WithDebuggingMetrics(true);
}

_logger.LogInformation("Starting prometheus-net.DotNetRuntime...");

builder.StartCollecting();
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions