From 8ebc29d1b9155c883c7de66183ae0166caa11761 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 8 Apr 2015 17:09:36 -0700 Subject: [PATCH] vault: audit broker profiles each backend --- vault/audit.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vault/audit.go b/vault/audit.go index 5c9002517..ad1a15755 100644 --- a/vault/audit.go +++ b/vault/audit.go @@ -269,7 +269,10 @@ func (a *AuditBroker) LogRequest(auth *logical.Auth, req *logical.Request) error // Ensure at least one backend logs anyLogged := false for name, be := range a.backends { - if err := be.backend.LogRequest(auth, req); err != nil { + start := time.Now() + err := be.backend.LogRequest(auth, req) + metrics.MeasureSince([]string{"audit", name, "log_request"}, start) + if err != nil { a.logger.Printf("[ERR] audit: backend '%s' failed to log request: %v", name, err) } else { anyLogged = true @@ -292,7 +295,10 @@ func (a *AuditBroker) LogResponse(auth *logical.Auth, req *logical.Request, // Ensure at least one backend logs anyLogged := false for name, be := range a.backends { - if err := be.backend.LogResponse(auth, req, resp, err); err != nil { + start := time.Now() + err := be.backend.LogResponse(auth, req, resp, err) + metrics.MeasureSince([]string{"audit", name, "log_response"}, start) + if err != nil { a.logger.Printf("[ERR] audit: backend '%s' failed to log response: %v", name, err) } else { anyLogged = true