prometheus-net

Форк
0
/
IMetricFactory.cs 
48 строк · 2.9 Кб
1
using System.ComponentModel;
2

3
namespace Prometheus;
4

5
/// <summary>
6
/// Allows for substitution of MetricFactory in tests.
7
/// You cannot provide your own implementation to prometheus-net code, only to your own code.
8
/// </summary>
9
public interface IMetricFactory
10
{
11
    // These require you to allocate a Configuration for each instance, which can be wasteful because often the only thing that differs is the label names.
12
    // We will mark them as non-browsable to discourage their use. They still work, so they are not obsolete or anything like that. Just discouraged.
13
    [EditorBrowsable(EditorBrowsableState.Never)]
14
    Counter CreateCounter(string name, string help, CounterConfiguration? configuration = null);
15
    [EditorBrowsable(EditorBrowsableState.Never)]
16
    Gauge CreateGauge(string name, string help, GaugeConfiguration? configuration = null);
17
    [EditorBrowsable(EditorBrowsableState.Never)]
18
    Histogram CreateHistogram(string name, string help, HistogramConfiguration? configuration = null);
19
    [EditorBrowsable(EditorBrowsableState.Never)]
20
    Summary CreateSummary(string name, string help, SummaryConfiguration? configuration = null);
21

22
    // These allow you to reuse a Configuration and only provide the label names. The reduced memory allocations can make a difference in high performance scenarios.
23
    // If label names are provided in both, they must match. Otherwise, label names in the Configuration object may be null.
24
    Counter CreateCounter(string name, string help, string[] labelNames, CounterConfiguration? configuration = null);
25
    Gauge CreateGauge(string name, string help, string[] labelNames, GaugeConfiguration? configuration = null);
26
    Histogram CreateHistogram(string name, string help, string[] labelNames, HistogramConfiguration? configuration = null);
27
    Summary CreateSummary(string name, string help, string[] labelNames, SummaryConfiguration? configuration = null);
28

29
    /// <summary>
30
    /// Returns a new metric factory that will add the specified labels to any metrics created using it.
31
    /// </summary>
32
    IMetricFactory WithLabels(IDictionary<string, string> labels);
33

34
    /// <summary>
35
    /// Returns a factory that creates metrics with a managed lifetime.
36
    /// </summary>
37
    /// <param name="expiresAfter">
38
    /// Metrics created from this factory will expire after this time span elapses, enabling automatic deletion of unused metrics.
39
    /// The expiration timer is reset to zero for the duration of any active lifetime-extension lease that is taken on a specific metric.
40
    /// </param>
41
    IManagedLifetimeMetricFactory WithManagedLifetime(TimeSpan expiresAfter);
42

43
    /// <summary>
44
    /// Allows you to configure how exemplars are applied to published metrics. If null, uses default behavior (see <see cref="ExemplarBehavior"/>).
45
    /// This is inherited by all metrics by default, although may be overridden in the configuration of an individual metric.
46
    /// </summary>
47
    ExemplarBehavior? ExemplarBehavior { get; set; }
48
}
49

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.