GaugeAttribute 类

定义

提供有关指导生产强类型仪表指标工厂方法和关联类型的信息。

public ref class GaugeAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class GaugeAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type GaugeAttribute = class
    inherit Attribute
Public NotInheritable Class GaugeAttribute
Inherits Attribute
继承
GaugeAttribute
属性

示例

static partial class Metric
{
    [Gauge]
    static partial MemoryUsage CreateMemoryUsage(Meter meter);
}

注解

此属性应用于具有以下约束的方法:

  • 必须是分部方法。
  • 必须作为类型返回 metricName 。 将生成具有该名称的类。
  • 不能为泛型。
  • 必须具有 System.Diagnostics.Metrics.Meter 作为第一个参数。
  • 必须具有作为字符串类型参数提供 staticTags 的所有键。

构造函数

名称 说明
GaugeAttribute(String[])

初始化 GaugeAttribute 类的新实例。

GaugeAttribute(Type)

初始化 GaugeAttribute 类的新实例。

属性

名称 说明
Name

获取或设置指标的名称。

TagNames

获取指标的标记名称。

Type

获取提供指标标记值的类型。

Unit

获取或设置指标的度量单位。

适用于