Bagikan melalui


GaugeAttribute<T> Kelas

Definisi

Menyediakan informasi untuk memandu produksi metode pabrik metrik pengukur yang sangat ditik dan jenis terkait.

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

Jenis parameter

T

Jenis nilai yang akan dipegang alat ukur, yang terbatas pada Byte, , Int16, Int32Int64, Single, Double, atau Decimal.

Warisan
GaugeAttribute<T>
Atribut

Contoh

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

Keterangan

Atribut ini diterapkan ke metode yang memiliki batasan berikut:

  • Harus berupa metode parsial.
  • Harus kembali metricName sebagai jenis. Kelas dengan nama tersebut akan dihasilkan.
  • Tidak boleh generik.
  • Harus memiliki System.Diagnostics.Metrics.Meter parameter pertama.
  • Harus memiliki semua kunci yang disediakan sebagai staticTags parameter jenis string.

Konstruktor

Nama Deskripsi
GaugeAttribute<T>(String[])

Menginisialisasi instans baru dari kelas GaugeAttribute<T>.

GaugeAttribute<T>(Type)

Menginisialisasi instans baru dari kelas GaugeAttribute<T>.

Properti

Nama Deskripsi
Name

Mendapatkan atau mengatur nama metrik.

TagNames

Mendapatkan nama tag metrik.

Type

Mendapatkan jenis yang menyediakan nilai tag metrik.

Unit

Mendapatkan atau mengatur unit pengukuran untuk metrik.

Berlaku untuk