mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 23:42:51 +08:00
Instrumentation: log the total number of db queries per request (#54647)
Signed-off-by: bergquist <carl.bergquist@gmail.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
19
pkg/infra/log/databaseCounter_test.go
Normal file
19
pkg/infra/log/databaseCounter_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCountingDatabaseCalls(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
ctx = IncDBCallCounter(ctx)
|
||||
ctx = IncDBCallCounter(ctx)
|
||||
ctx = IncDBCallCounter(ctx)
|
||||
|
||||
count := TotalDBCallCount(ctx)
|
||||
assert.Equal(t, int64(3), count, "expect counter to increase three times")
|
||||
}
|
Reference in New Issue
Block a user