語言

CounterAttribute 類別

定義

提供資訊,以引導強型別 64 位整數計數器計量處理站方法和相關聯型別的生產。

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

範例

static partial class Metric
{
    [Counter("RequestName", "RequestStatusCode")]
    static partial RequestCounter CreateRequestCounter(Meter meter);
}

備註

此屬性應用於具有以下限制的方法:

  • 一定是部分方法。
  • 必須返回 metricName 為類型。 會產生一個名為該名稱的類別。
  • 不能是通用的。
  • 必須是第一個 System.Diagnostics.Metrics.Meter 參數。
  • 必須將所有鍵以字串類型參數的形式提供 staticTagNames 。

建構函式

名稱 Description
CounterAttribute(String[])

初始化 CounterAttribute 類別的新執行個體。

CounterAttribute(Type)

初始化 CounterAttribute 類別的新執行個體。

屬性

名稱 Description
Name

取得或設定指標名稱。

TagNames

取得指標的標籤名稱。

Type

取得提供指標標籤值的類型。

Unit

取得或設定公制的計量單位。

適用於