GaugeAttribute<T> Třída

Definice

Poskytuje informace pro vedení produkce metody metriky se silnými typy měřidla a přidruženého typu.

generic <typename T>
 where T : value classpublic ref class GaugeAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
[System.Diagnostics.CodeAnalysis.Experimental("EXTEXP0003", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class GaugeAttribute<T> : Attribute where T : struct
[System.AttributeUsage(System.AttributeTargets.Method)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class GaugeAttribute<T> : Attribute where T : struct
[<System.AttributeUsage(System.AttributeTargets.Method)>]
[<System.Diagnostics.CodeAnalysis.Experimental("EXTEXP0003", UrlFormat="https://aka.ms/dotnet-extensions-warnings/{0}")>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type GaugeAttribute<'T (requires 'T : struct)> = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type GaugeAttribute<'T (requires 'T : struct)> = class
    inherit Attribute
Public NotInheritable Class GaugeAttribute(Of T)
Inherits Attribute

Parametry typu

T

Typ hodnoty měřidla bude obsahovat, což je omezeno na Byte, Int16, Int32, Int64, , DoubleSinglenebo Decimal.

Dědičnost
GaugeAttribute<T>
Atributy

Příklady

static partial class Metric
{
    [Gauge<double>("MemoryUsage", "Region")]
    static partial MemoryGauge CreateMemoryGauge(Meter meter);
}

Poznámky

Tento atribut se použije u metody, která má následující omezení:

  • Musí to být částečná metoda.
  • Musí se vrátit metricName jako typ. Vygeneruje se třída s tímto názvem.
  • Nesmí být obecný.
  • Musí mít System.Diagnostics.Metrics.Meter jako první parametr.
  • Musí obsahovat všechny klíče zadané staticTags jako parametry typu řetězce.

Konstruktory

Name Description
GaugeAttribute<T>(String[])

Inicializuje novou instanci GaugeAttribute<T> třídy.

GaugeAttribute<T>(Type)

Inicializuje novou instanci GaugeAttribute<T> třídy.

Vlastnosti

Name Description
Name

Získá nebo nastaví název metriky.

TagNames

Získá názvy značek metriky.

Type

Získá typ, který poskytuje hodnoty značek metriky.

Unit

Získá nebo nastaví měrnou jednotku pro metriku.

Platí pro