-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Prometheus metric to track exec querys per transaction
* Added two counter to track exec and query statements seperately. * UTs added for the same.
- Loading branch information
1 parent
1bff9ed
commit 612f262
Showing
7 changed files
with
287 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package hotload | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
var _ = Describe("PrometheusMetric", func() { | ||
It("Should register a prometheus metric", func() { | ||
// This test is a placeholder for a real test | ||
err := prometheus.Register(sqlStmtsSummary) | ||
Expect(err).Should(HaveOccurred()) | ||
Expect(errors.As(err, &prometheus.AlreadyRegisteredError{})).Should(BeTrue()) | ||
}) | ||
}) | ||
|
||
var _ = Describe("PromUnaryServerInterceptor", func() { | ||
It("Should return a unary server interceptor", func() { | ||
validationHandler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||
labels := GetExecLabelsFromContext(ctx) | ||
|
||
Expect(labels).ShouldNot(BeNil()) | ||
Expect(labels[GRPCMethodKey]).Should(Equal("List")) | ||
Expect(labels[GRPCServiceKey]).Should(Equal("infoblox.service.SampleService")) | ||
|
||
return nil, nil | ||
} | ||
|
||
promUnaryServerInterceptor := PromUnaryServerInterceptor() | ||
promUnaryServerInterceptor(context.Background(), struct{}{}, &grpc.UnaryServerInfo{ | ||
FullMethod: "/infoblox.service.SampleService/List", | ||
}, validationHandler) | ||
}) | ||
}) |
Oops, something went wrong.