Skip to content

Commit

Permalink
remove duplicated metrics config
Browse files Browse the repository at this point in the history
  • Loading branch information
smantic committed Nov 2, 2024
1 parent 799ac13 commit a30f3b6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 38 deletions.
98 changes: 60 additions & 38 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,55 +322,77 @@ func loggerFromFlags(cmd *cli.Command) *slog.Logger {
func newMetrics() *metrics.Metrics {
return &metrics.Metrics{
TMIMsgsCount: metrics.NewPromCounter(
prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "tmi",
Name: "messages",
Help: "Number of PRIVMSGs received from TMI.",
}),
prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "tmi",
Name: "messages",
Help: "Number of PRIVMSGs received from TMI.",
},
),
),
TMICommandCount: metrics.NewPromCounter(
prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "tmi",
Name: "commands",
Help: "Number of command invocations received in Twitch chat.",
}),
prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "tmi",
Name: "commands",
Help: "Number of command invocations received in Twitch chat.",
},
),
),
LearnedCount: metrics.NewPromCounter(
prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "brain",
Name: "learned",
Help: "Number of messages learned.",
}),
prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "brain",
Name: "learned",
Help: "Number of messages learned.",
},
),
),
ForgotCount: metrics.NewPromCounter(
prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "brain",
Name: "forgot",
Help: "Number of individual messages deleted. Does not include messages deleted by user or time.",
}),
prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "robot",
Subsystem: "brain",
Name: "forgot",
Help: "Number of individual messages deleted. Does not include messages deleted by user or time.",
},
),
),
SpeakLatency: metrics.NewPromObserverVec(
prometheus.NewHistogramVec(prometheus.HistogramOpts{
Buckets: []float64{0.01, 0.05, 0.1, 0.2, 0.5, 1, 5, 10},
Namespace: "robot",
Subsystem: "commands",
Name: "speak-latency",
Help: "How long it takes for robot to speak once prompted in seconds",
}, []string{"channel", "empty-prompt"},
prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Buckets: []float64{0.01, 0.05, 0.1, 0.2, 0.5, 1, 5, 10},
Namespace: "robot",
Subsystem: "commands",
Name: "speak-latency",
Help: "How long it takes for robot to speak once prompted in seconds",
},
[]string{"channel", "empty-prompt"},
),
),
LearnLatency: metrics.NewPromObserverVec(
prometheus.NewHistogramVec(prometheus.HistogramOpts{
Buckets: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
Namespace: "robot",
Subsystem: "brain",
Name: "learn-latency",
Help: "How long it takes robot to learn a non discarded message in seconds",
}, []string{"channel"},
prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Buckets: []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
Namespace: "robot",
Subsystem: "brain",
Name: "learn-latency",
Help: "How long it takes robot to learn a non discarded message in seconds",
},
[]string{"channel"},
),
),
UsedMessagesForGeneration: metrics.NewPromHistogram(
prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "robot",
Subsystem: "commands",
Name: "used-messages",
Help: "How many messages were used while generating a new message",
},
),
),
}
Expand Down
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ func (m Metrics) Collectors() []prometheus.Collector {
m.TMICommandCount,
m.TMIMsgsCount,
m.LearnLatency,
m.UsedMessagesForGeneration,
}
}

0 comments on commit a30f3b6

Please sign in to comment.