metrics

package
v0.0.0-...-60b0928 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// States: "pending" (in bot's worker queue), "processing" (actively handled),
	//         "unauthorized" (terminal state for disallowed messages),
	//         "failed" (terminal state for error occurred while handling messages),
	//         "processed" (terminal state for successfully handled messages).
	MetricMessages = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "messages_total",
			Help:      "Current number of messages being processed by the bot.",
		},
		[]string{"state", "chat_type"},
	)

	// States: "pending" (waiting for rate limiter),
	//         "processing" (waiting for translation API response),
	//         "success" (translation and parsing successful),
	//         "failed" (any step in translation failed).
	MetricTranslatorTasks = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "translator_tasks_total",
			Help:      "Total number of translation tasks, by state.",
		},
		[]string{"state", "translator_name"},
	)

	// Types: "completion" (output tokens)
	// 		  "prompt" (input tokens)
	MetricTranslatorTokensUsed = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "translator_tokens_used",
			Help:      "Used tokens of translation tasks.",
		},
		[]string{"token_type", "translator_name"},
	)

	// Gauge for translator up status
	// Value is 1 if the translator is up, 0 if it is disabled.
	MetricTranslatorUp = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "translator_up",
			Help:      "Indicates if a translator is currently up and operational. 1 for up, 0 for disabled.",
		},
		[]string{"translator_name"},
	)

	// Gauge for translator selected times
	MetricTranslatorSelectionTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "translator_selection_total",
			Help:      "Times of translator instance was chosen.",
		},
		[]string{"translator_name"},
	)

	// States: "pending" (waiting for rate limiter),
	//         "processing" (waiting for translation API response),
	//         "success" (translation and parsing successful),
	//         "failed" (any step in translation failed).
	MetricDetectorTasks = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "detector_tasks_total",
			Help:      "Total number of translation tasks, by state.",
		},
		[]string{"state", "detector_name"},
	)

	// Gauge for detector up status
	// Value is 1 if the detector is up, 0 if it is disabled.
	MetricDetectorUp = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "detector_up",
			Help:      "Indicates if a detector is currently up and operational. 1 for up, 0 for disabled.",
		},
		[]string{"detector_name"},
	)

	// Gauge for detector selected times
	MetricDetectorSelectionTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "detector_selection_total",
			Help:      "Times of detector instance was chosen.",
		},
		[]string{"detector_name"},
	)
)

Functions

func InitMetricServer

func InitMetricServer(conf MetricConfig)

Types

type MetricConfig

type MetricConfig struct {
	Listen string `yaml:"listen"`
}

Jump to

Keyboard shortcuts

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