feat: add error-event metric
This commit is contained in:
parent
0ce69d9b5b
commit
38f9a75157
1 changed files with 13 additions and 0 deletions
13
main.go
13
main.go
|
@ -20,6 +20,7 @@ type Telemetry struct {
|
|||
type metrics struct {
|
||||
buffering *prometheus.CounterVec
|
||||
recovery *prometheus.CounterVec
|
||||
errorMetric *prometheus.CounterVec
|
||||
qualityUp *prometheus.CounterVec
|
||||
qualityDown *prometheus.CounterVec
|
||||
}
|
||||
|
@ -27,6 +28,7 @@ type metrics struct {
|
|||
const (
|
||||
typeBuffering = "buffering"
|
||||
typeRecovery = "recovery"
|
||||
typeError = "error"
|
||||
typeQualitySwitch = "quality_switch"
|
||||
)
|
||||
|
||||
|
@ -97,6 +99,12 @@ func initMetrics() (metrics, error) {
|
|||
Name: "recovery",
|
||||
}, []string{"slug"})
|
||||
|
||||
metricError := prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: "telemetry",
|
||||
Subsystem: "player",
|
||||
Name: "error",
|
||||
}, []string{"slug"})
|
||||
|
||||
metricQualitySwitchUp := prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: "telemetry",
|
||||
Subsystem: "player",
|
||||
|
@ -117,6 +125,10 @@ func initMetrics() (metrics, error) {
|
|||
return metrics{}, fmt.Errorf("failed to register recovery metric: %w", err)
|
||||
}
|
||||
|
||||
if err := prometheus.Register(metricError); err != nil {
|
||||
return metrics{}, fmt.Errorf("failed to register error metric: %w", err)
|
||||
}
|
||||
|
||||
if err := prometheus.Register(metricQualitySwitchUp); err != nil {
|
||||
return metrics{}, fmt.Errorf("failed to register quality_switch_up metric: %w", err)
|
||||
}
|
||||
|
@ -128,6 +140,7 @@ func initMetrics() (metrics, error) {
|
|||
return metrics{
|
||||
buffering: metricBuffering,
|
||||
recovery: metricRecovery,
|
||||
errorMetric: metricError,
|
||||
qualityUp: metricQualitySwitchUp,
|
||||
qualityDown: metricQualitySwitchDown,
|
||||
}, nil
|
||||
|
|
Loading…
Reference in a new issue