telmetry: add databroker storage metrics and tracing (#1161)

* telmetry: add databroker storage metrics and tracing
This commit is contained in:
Travis Groth 2020-07-30 18:19:23 -04:00 committed by GitHub
parent 29fb96a955
commit 3c4513a91e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 255 additions and 15 deletions

View file

@ -0,0 +1,33 @@
package metrics
import (
"context"
"errors"
"testing"
"time"
"go.opencensus.io/stats/view"
)
func Test_RecordStorageOperation(t *testing.T) {
tests := []struct {
name string
tags *StorageOperationTags
duration time.Duration
want string
}{
{"success", &StorageOperationTags{Operation: "test", Backend: "testengine"}, time.Millisecond * 5, "{ { {backend testengine}{operation test}{result success}{service databroker} }&{1 5 5 5 0"},
{"error", &StorageOperationTags{Operation: "failtest", Backend: "failengine", Error: errors.New("failure")}, time.Millisecond * 5, "{ { {backend failengine}{operation failtest}{result error}{service databroker} }&{1 5 5 5 0"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
view.Unregister(StorageViews...)
view.Register(StorageViews...)
RecordStorageOperation(context.Background(), tt.tags, tt.duration)
testDataRetrieval(StorageOperationDurationView, t, tt.want)
})
}
}