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 {
|
type metrics struct {
|
||||||
buffering *prometheus.CounterVec
|
buffering *prometheus.CounterVec
|
||||||
recovery *prometheus.CounterVec
|
recovery *prometheus.CounterVec
|
||||||
|
errorMetric *prometheus.CounterVec
|
||||||
qualityUp *prometheus.CounterVec
|
qualityUp *prometheus.CounterVec
|
||||||
qualityDown *prometheus.CounterVec
|
qualityDown *prometheus.CounterVec
|
||||||
}
|
}
|
||||||
|
@ -27,6 +28,7 @@ type metrics struct {
|
||||||
const (
|
const (
|
||||||
typeBuffering = "buffering"
|
typeBuffering = "buffering"
|
||||||
typeRecovery = "recovery"
|
typeRecovery = "recovery"
|
||||||
|
typeError = "error"
|
||||||
typeQualitySwitch = "quality_switch"
|
typeQualitySwitch = "quality_switch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -97,6 +99,12 @@ func initMetrics() (metrics, error) {
|
||||||
Name: "recovery",
|
Name: "recovery",
|
||||||
}, []string{"slug"})
|
}, []string{"slug"})
|
||||||
|
|
||||||
|
metricError := prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
|
Namespace: "telemetry",
|
||||||
|
Subsystem: "player",
|
||||||
|
Name: "error",
|
||||||
|
}, []string{"slug"})
|
||||||
|
|
||||||
metricQualitySwitchUp := prometheus.NewCounterVec(prometheus.CounterOpts{
|
metricQualitySwitchUp := prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: "telemetry",
|
Namespace: "telemetry",
|
||||||
Subsystem: "player",
|
Subsystem: "player",
|
||||||
|
@ -117,6 +125,10 @@ func initMetrics() (metrics, error) {
|
||||||
return metrics{}, fmt.Errorf("failed to register recovery metric: %w", err)
|
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 {
|
if err := prometheus.Register(metricQualitySwitchUp); err != nil {
|
||||||
return metrics{}, fmt.Errorf("failed to register quality_switch_up metric: %w", err)
|
return metrics{}, fmt.Errorf("failed to register quality_switch_up metric: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -128,6 +140,7 @@ func initMetrics() (metrics, error) {
|
||||||
return metrics{
|
return metrics{
|
||||||
buffering: metricBuffering,
|
buffering: metricBuffering,
|
||||||
recovery: metricRecovery,
|
recovery: metricRecovery,
|
||||||
|
errorMetric: metricError,
|
||||||
qualityUp: metricQualitySwitchUp,
|
qualityUp: metricQualitySwitchUp,
|
||||||
qualityDown: metricQualitySwitchDown,
|
qualityDown: metricQualitySwitchDown,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
Loading…
Reference in a new issue