Skip to content

Commit e3278c6

Browse files
committed
feat: cache hit span
1 parent 205d128 commit e3278c6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/engines/cache/cache.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/hex"
66

7+
"go.opentelemetry.io/otel"
78
api "go.opentelemetry.io/otel/metric"
89

910
"github.com/cespare/xxhash/v2"
@@ -15,6 +16,8 @@ import (
1516
base "github.com/Permify/permify/pkg/pb/base/v1"
1617
)
1718

19+
var tracer = otel.Tracer("check-cache")
20+
1821
// CheckEngineWithCache is a struct that holds an instance of a cache.Cache for managing engine cache.
1922
type CheckEngineWithCache struct {
2023
// schemaReader is responsible for reading schema information
@@ -69,6 +72,9 @@ func (c *CheckEngineWithCache) Check(ctx context.Context, request *base.Permissi
6972

7073
// If a cached result is found, handle exclusion and return the result.
7174
if found {
75+
ctx, span := tracer.Start(ctx, "hit")
76+
defer span.End()
77+
7278
// Increase the check count in the metrics.
7379
c.cacheCounter.Add(ctx, 1)
7480
// If the request doesn't have the exclusion flag set, return the cached result.

0 commit comments

Comments
 (0)