diff --git a/pkg/auth/metrics.go b/pkg/auth/metrics.go index afcca39..607da3a 100644 --- a/pkg/auth/metrics.go +++ b/pkg/auth/metrics.go @@ -43,7 +43,7 @@ var ( Help: "CheckRequest durations (response times)", Buckets: DurationBuckets, }, - []string{CerberusReasonLabel, CheckRequestVersionLabel, HasUpstreamAuth, WebserviceLabel}, + []string{CerberusReasonLabel, CheckRequestVersionLabel, HasUpstreamAuth}, ) cacheUpdateCount = prometheus.NewCounter( @@ -150,7 +150,7 @@ func init() { upstreamAuthFailedRequests, ) } -///server + func AddReasonLabel(labels prometheus.Labels, reason CerberusReason) prometheus.Labels { if labels == nil { labels = prometheus.Labels{} @@ -158,7 +158,7 @@ func AddReasonLabel(labels prometheus.Labels, reason CerberusReason) prometheus. labels[CerberusReasonLabel] = string(reason) return labels } -///auth-cache + func AddKindLabel(labels prometheus.Labels, kind string) prometheus.Labels { if labels == nil { labels = prometheus.Labels{} @@ -166,7 +166,7 @@ func AddKindLabel(labels prometheus.Labels, kind string) prometheus.Labels { labels[ObjectKindLabel] = kind return labels } -///auth + func AddStatusLabel(labels prometheus.Labels, status int) prometheus.Labels { if labels == nil { labels = prometheus.Labels{} @@ -174,7 +174,7 @@ func AddStatusLabel(labels prometheus.Labels, status int) prometheus.Labels { labels[StatusCode] = strconv.Itoa(status) return labels } -///server + func AddUpstreamAuthLabel(labels prometheus.Labels, hasUpstreamAuth string) prometheus.Labels { if labels == nil { labels = prometheus.Labels{} @@ -182,7 +182,7 @@ func AddUpstreamAuthLabel(labels prometheus.Labels, hasUpstreamAuth string) prom labels[HasUpstreamAuth] = hasUpstreamAuth return labels } -//auth + func AddWithDownstreamDeadlineLabel(labels prometheus.Labels, hasDeadline bool) prometheus.Labels { if labels == nil { labels = prometheus.Labels{} @@ -194,7 +194,7 @@ func AddWithDownstreamDeadlineLabel(labels prometheus.Labels, hasDeadline bool) } return labels } -///server + func AddWebserviceLabel(labels prometheus.Labels, wsvc string) prometheus.Labels { if labels == nil { labels = prometheus.Labels{} diff --git a/pkg/auth/server.go b/pkg/auth/server.go index 2179541..e5e6f40 100644 --- a/pkg/auth/server.go +++ b/pkg/auth/server.go @@ -47,10 +47,11 @@ func (a *authV2) Check(ctx context.Context, check *CheckRequestV2) (*CheckRespon reason := CerberusReason(response.Response.Header.Get(CerberusHeaderReasonHeader)) labels := AddReasonLabel(nil, reason) labels = AddUpstreamAuthLabel(labels, request.Context[HasUpstreamAuth]) - labels = AddWebserviceLabel(labels, string(CerberusHeaderWebservice)) labels[CheckRequestVersionLabel] = MetricsCheckRequestVersion2 - reqCount.With(labels).Inc() reqLatency.With(labels).Observe(time.Since(reqStartTime).Seconds()) + labels = AddWebserviceLabel(labels, string(CerberusHeaderWebservice)) + reqCount.With(labels).Inc() + return final_response, nil } @@ -74,10 +75,10 @@ func (a *authV3) Check(ctx context.Context, check *CheckRequestV3) (*CheckRespon reason := CerberusReason(response.Response.Header.Get(CerberusHeaderReasonHeader)) labels := AddReasonLabel(nil, reason) labels = AddUpstreamAuthLabel(labels, request.Context[HasUpstreamAuth]) - labels = AddWebserviceLabel(labels, string(CerberusHeaderWebservice)) labels[CheckRequestVersionLabel] = MetricsCheckRequestVersion3 - reqCount.With(labels).Inc() reqLatency.With(labels).Observe(time.Since(reqStartTime).Seconds()) + labels = AddWebserviceLabel(labels, string(CerberusHeaderWebservice)) + reqCount.With(labels).Inc() return final_response, nil }