来自 Prometheus .NET 客户端库的 Metrics 实例是线程安全的吗

Are Metrics instances from the Prometheus .NET client library thread-safe

对于 prometheus-net,none 个示例特别清楚地表明给定 Metric 的实例是否是线程安全的:

即在随机控制器方法中,我应该这样做吗:

static readonly Histogram xyzMetric = Metrics.CreateHistogram(...)

或者我总是创建一个本地实例并管理它而不跨线程共享它的预期用途?

鉴于涉及的各种配置 DSLery,我相信答案是肯定的 ()...我说得对吗?

As of 30 Jan 2019, https://github.com/prometheus-net/prometheus-net#best-practices-and-usage 表示

The library is thread-safe

但是,有一些元素,例如直方图,由于收集指标的方式无法保证,然后为抓取呈现,这可能会产生非常小的故障,例如正如 https://github.com/prometheus-net/prometheus-net/blob/master/Prometheus.NetStandard/Histogram.cs#L10

中所述
/// The histogram is thread-safe but not atomic - the sum of values and total count of events
/// may not add up perfectly with bucket contents if new observations are made during a collection.