Skip to content

Commit

Permalink
metric: track the plugin start time (#347)
Browse files Browse the repository at this point in the history
This allows for annotations on the dashboard showing plugin (or server) restart events.
  • Loading branch information
lieut-data authored Oct 17, 2023
1 parent 370fddc commit bb6e711
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

const (
MetricsNamespace = "msteams_connect"
MetricsSubsystemSystem = "system"
MetricsSubsystemApp = "app"
MetricsSubsystemHTTP = "http"
MetricsSubsystemAPI = "api"
Expand All @@ -23,6 +24,8 @@ type InstanceInfo struct {
type Metrics struct {
registry *prometheus.Registry

pluginStartTime prometheus.Gauge

apiTime *prometheus.HistogramVec

httpRequestsTotal prometheus.Counter
Expand Down Expand Up @@ -53,6 +56,16 @@ func NewMetrics(info InstanceInfo) *Metrics {
additionalLabels[MetricsCloudInstallationLabel] = info.InstallationID
}

m.pluginStartTime = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: MetricsNamespace,
Subsystem: MetricsSubsystemSystem,
Name: "plugin_start_time",
Help: "The time the plugin started.",
ConstLabels: additionalLabels,
})
m.pluginStartTime.SetToCurrentTime()
m.registry.MustRegister(m.pluginStartTime)

m.apiTime = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: MetricsNamespace,
Expand Down

0 comments on commit bb6e711

Please sign in to comment.