Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions internal/invoke/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ func (invoker *DirectInvoker) Check(ctx context.Context, request *base.Permissio
attribute.KeyValue{Key: "subject", Value: attribute.StringValue(tuple.SubjectToString(request.GetSubject()))},
))
defer span.End()
// Use only bounded-cardinality `subject_type` as a metric label.
// Do NOT include `subject_id`: it has unbounded cardinality (one per end-user),
// causing OTel metric series to grow monotonically. Each Prometheus scrape then
// triggers `aggregate.reset` to allocate hundreds of MB, leading to a GC storm
// where mark/scan workers consume 80%+ CPU.
invoker.checkHistogram.Record(ctx, 1,
metric.WithAttributeSet(
attribute.NewSet(
attribute.KeyValue{Key: "subject_id", Value: attribute.StringValue(request.GetSubject().GetId())},
attribute.KeyValue{Key: "subject_type", Value: attribute.StringValue(request.GetSubject().GetType())},
)),
metric.WithAttributes(
attribute.String("subject_type", request.GetSubject().GetType()),
),
)

// Validate the depth of the request.
Expand Down
Loading