語言

CounterAttribute<T> 類別

定義

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

generic <typename T>
 where T : value classpublic ref class CounterAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class CounterAttribute<T> : Attribute where T : struct
[<System.AttributeUsage(System.AttributeTargets.Method)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type CounterAttribute<'T (requires 'T : struct)> = class
    inherit Attribute
Public NotInheritable Class CounterAttribute(Of T)
Inherits Attribute

類型參數

T

計數器所能持有的值類型,限制為 Byte、 Int16、 DecimalInt32Int64SingleDouble或 。

繼承
CounterAttribute<T>
屬性

範例

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

備註

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

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

建構函式

名稱 Description
CounterAttribute<T>(String[])

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

CounterAttribute<T>(Type)

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

屬性

名稱 Description
Name

取得或設定指標名稱。

TagNames

取得指標的標籤名稱。

Type

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

Unit

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

適用於