Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Modern .NET Meter metrics start to be collected only after very first Export #487

@rr-media

Description

@rr-media

Hello,

I'm trying to collect new .NET Meter stuff with prometheus-net and noticed some strange behaviour. If I collect metrics using

    await Prometheus.Metrics.DefaultRegistry.CollectAndExportAsTextAsync(memoryStream, cancellationToken);

I just get only one metric - prometheus_net_meteradapter_instruments_connected

And only second call to the same method will return real metrics, for example from system.http or microsoft.aspnetcore.

Looks like that first call performs sort of bootstrap and only after this call library really starts listening .NET metrics.

Although it's easy to add the call to CollectAndExportAsTextAsync in the beginning of Program.cs, it looks a bit "hacky", maybe there is a better way to "bootstrap" things or we need to introduce one.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions