Skip to content

Commit

Permalink
Add metrics for index insertion (#2015)
Browse files Browse the repository at this point in the history
Add new summary vector metric `rekor_index_storage_latency_summary` to
enable tracking latency of entry insertion in the mysql or redis index
storage backend.

Since the index insertion is non-blocking, the existing API metrics are
unable to measure its latency. However, the speed of insertion affects
how fast the index is available to query, so it is relevant to rekor's
overall performance.

This new metric along with the existing API metrics will help give an
clearer picture of rekor's index storage performance.

Signed-off-by: Colleen Murphy <[email protected]>
  • Loading branch information
cmurphy authored Feb 23, 2024
1 parent 78c8c42 commit 006b846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/api/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"time"

"github.com/cyberphone/json-canonicalization/go/src/webpki.org/jsoncanonicalizer"
"github.com/go-openapi/runtime"
Expand Down Expand Up @@ -246,6 +248,14 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl

if indexStorageClient != nil {
go func() {
start := time.Now()
var err error
defer func() {
labels := map[string]string{
"success": strconv.FormatBool(err == nil),
}
metricIndexStorageLatency.With(labels).Observe(float64(time.Since(start)))
}()
keys, err := entry.IndexKeys()
if err != nil {
log.ContextLogger(ctx).Errorf("getting entry index keys: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ var (
Help: "The status of publishing events to Pub/Sub",
}, []string{"event", "content_type", "status"})

metricIndexStorageLatency = promauto.NewSummaryVec(prometheus.SummaryOpts{
Name: "rekor_index_storage_latency_summary",
Help: "Latency of backend index insertion by success/failure",
}, []string{"success"})

MetricLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
Name: "rekor_api_latency",
Help: "Api Latency on calls",
Expand Down

0 comments on commit 006b846

Please sign in to comment.