Skip to content

Commit

Permalink
feat: complete metric interface
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Nov 23, 2024
1 parent a842ee9 commit 28976b7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/metric/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package metric

import (
"errors"
"strconv"

"github.com/prometheus/client_golang/prometheus"
"github.com/snapp-incubator/soteria/internal/authenticator"
Expand All @@ -21,8 +22,8 @@ func NewAutoAuthenticatorMetrics() *AutoAuthenticatorMetrics {
latency: prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "platform",
Subsystem: "soteria",
Name: "auto_auth_latency",
Help: "Automatic authentication latency",
Name: "auto_auth_latency_seconds",
Help: "Automatic authentication latency in seconds",
ConstLabels: prometheus.Labels{},
Buckets: prometheus.DefBuckets,
NativeHistogramBucketFactor: 0,
Expand All @@ -40,6 +41,11 @@ func NewAutoAuthenticatorMetrics() *AutoAuthenticatorMetrics {
return m
}

// Latency measures latency in seconds.
func (m *AutoAuthenticatorMetrics) Latency(latency float64, company string, status int) {
m.latency.WithLabelValues(company, strconv.Itoa(status)).Observe(latency)
}

func (m *AutoAuthenticatorMetrics) register() {
register(m.latency)
}
Expand Down

0 comments on commit 28976b7

Please sign in to comment.