Skip to content

Commit

Permalink
add direct-to-prometheus metric for signer requests (#1095)
Browse files Browse the repository at this point in the history
We could have misunderstood what the problem is by looking at a metric
that only changed before the first scrape.

Updates AUT-393
Updates AUT-199
  • Loading branch information
jmhodges authored Jan 14, 2025
1 parent 0c16f44 commit 13cee03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import (
"net/url"
"os"
"path"
"strconv"
"time"

"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"

"github.com/mozilla-services/autograph/formats"
"github.com/mozilla-services/autograph/signer"
Expand Down Expand Up @@ -217,6 +219,12 @@ func (a *autographer) handleSignature(w http.ResponseWriter, r *http.Request) {
}
requestedSignerConfig := requestedSigner.Config()
a.stats.Incr("signer.requests", []string{"keyid:" + requestedSignerConfig.ID, "user:" + userid, usedDefaultSignerTag(sigreq)}, 1.0)
signerRequestsCounter.With(prometheus.Labels{
"keyid": requestedSignerConfig.ID,
"user": userid,
// TODO(AUT-206): remove this when we've migrate everyone off of the default keyid
"used_default_signer": strconv.FormatBool(sigreq.KeyID == ""),
}).Inc()

sigresps[i] = formats.SignatureResponse{
Ref: id(),
Expand Down
5 changes: 5 additions & 0 deletions stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ var (
Name: "prom_only_foobar_test",
Help: "A counter used for testing how prometheus and statsd metrics differ",
})

signerRequestsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "signer_requests",
Help: "A counter for how many authenticated and authorized requests are made to a given signer",
}, []string{"keyid", "user", "used_default_signer"})
)

func loadStatsd(conf configuration) (*statsd.Client, error) {
Expand Down

0 comments on commit 13cee03

Please sign in to comment.