metrics

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Copyright 2023 The K8sGPT Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricBuilder

type MetricBuilder struct {
	// contains filtered or unexported fields
}

MetricBuilder helps in building and registering Prometheus metrics

func InitializeMetrics

func InitializeMetrics() *MetricBuilder

Usage example

func NewMetricBuilder

func NewMetricBuilder() *MetricBuilder

NewMetricBuilder creates a new MetricBuilder instance

func (*MetricBuilder) AddMetric

func (b *MetricBuilder) AddMetric(config MetricConfig) *MetricBuilder

AddMetric adds a metric to the builder

func (*MetricBuilder) GetCounterVec

func (b *MetricBuilder) GetCounterVec(name string) *prometheus.CounterVec

GetCounterVec returns a specific CounterVec metric by name

func (*MetricBuilder) GetGaugeVec

func (b *MetricBuilder) GetGaugeVec(name string) *prometheus.GaugeVec

GetGaugeVec returns a specific GaugeVec metric by name

func (*MetricBuilder) RegisterMetrics

func (b *MetricBuilder) RegisterMetrics()

RegisterMetrics registers all metrics with Prometheus

type MetricConfig

type MetricConfig struct {
	Name   string
	Help   string
	Labels []string
	Type   MetricType
}

MetricConfig holds the configuration for a single metric

type MetricType

type MetricType int

MetricType represents the type of Prometheus metric (Counter or Gauge)

const (
	Counter MetricType = iota
	Gauge
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL