Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
func Marshal(metas ...*MetricMeta) ([]byte, error)
Marshal converts a slice of MetricMeta into a Prometheus-compatible byte slice. Parameters: - metas: []*MetricMeta - A slice of MetricMeta to be marshaled. Returns: - []byte: The marshaled data in Prometheus format. - error: An error that might occur during marshaling.
Types ¶
type Marshalable ¶
type Marshalable interface { // MarshalProm marshals the object into a slice of MetricData. MarshalProm() []MetricData }
Marshalable is an interface for objects that can be marshaled into MetricData.
type MetricData ¶
type MetricData struct { Labels map[string]string // Labels are key-value pairs that add context to the metric. Value any // Value is the actual data of the metric. }
MetricData represents the data for a metric, consisting of labels and a value.
type MetricLabel ¶
type MetricLabel struct { Key string // Key is the label key. Value string // Value is the label value. }
MetricLabel represents the data for a metric, consisting of labels and a value.
type MetricMeta ¶
type MetricMeta struct { Name string // Name of the metric. Help string // Help provides a description for the metric. Type string // Type of the metric (e.g., counter, gauge). Value []MetricData // Value contains the actual metric data to be marshaled. }
MetricMeta holds metadata for a metric including its name, help text, type, and value.
func NewMetricMeta ¶
func NewMetricMeta(name, help, metricType string, data Marshalable) (*MetricMeta, error)
NewMetricMeta creates a new MetricMeta instance. Parameters: - name: string - The name of the metric. - help: string - Help text describing the metric. - metricType: string - The type of the metric (e.g., counter, gauge). - data: Marshalable - The object that can be marshaled into MetricData. Returns: - *MetricMeta: A pointer to the newly created MetricMeta. - error: An error that might occur during the creation of MetricMeta.
func NewSimpleMeta ¶
func NewSimpleMeta(name, help, metricType string, value any, labels ...MetricLabel) *MetricMeta
NewSimpleMeta creates a new MetricData instance with a single value. Parameters: - name: string - The name of the metric. - help: string - Help text describing the metric. - metricType: string - The type of the metric (e.g., counter, gauge). - value: any - The value of the metric. - labels: map[string]string - Labels for the metric. Returns: - *MetricMeta: A pointer to the newly created MetricMeta.