Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels to vault_sign_request_duration Prometheus metrics #300

Merged
merged 13 commits into from
Jun 12, 2023
Merged
2 changes: 0 additions & 2 deletions integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ Github secrets are used to define vault env var used in github workflows. To run

### using GCP vault

If you want to run GCP vault tests you need to substitute GCP vault env var into the GCP token file that gets mounted to Signatory file system:

```sh
envsubst < gcp-token-template.json > gcp-token.json
```
Expand Down
16 changes: 9 additions & 7 deletions pkg/metrics/vaultmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
Name: "vault_sign_request_duration_milliseconds",
Help: "Vaults signing requests latencies in milliseconds",
Buckets: prometheus.ExponentialBuckets(10, 10, 5),
}, []string{"vault"})
}, []string{"vault", "address", "op"})

vaultErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand All @@ -41,12 +41,14 @@ var (
}, []string{"vault", "code"})
)

// Interceptor function collects sing operation metrics
func Interceptor(opt *signatory.SignInterceptorOptions, sing func() error) error {
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(seconds float64) {
vaultSigningHist.WithLabelValues(opt.Vault).Observe(seconds * 1000)
}))
err := sing()
// Interceptor function collects sign operation metrics
func Interceptor(opt *signatory.SignInterceptorOptions, sign func() error) error {
timer := prometheus.NewTimer(
prometheus.ObserverFunc(
func(seconds float64) {
vaultSigningHist.WithLabelValues(opt.Vault, string(opt.Address.ToBase58()), opt.Req).Observe(seconds * 1000)
}))
err := sign()
timer.ObserveDuration()

if err != nil {
Expand Down