Include resource name in the event. (#107185)

This commit is contained in:
Peter Štibraný
2025-06-27 11:29:49 +02:00
committed by GitHub
parent 53ec379af8
commit 2e9559a376
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -305,7 +305,7 @@ func (b *batchRunner) Next() bool {
// Mention resource in the span.
attrs := []attribute.KeyValue{
attribute.String("key", k),
attribute.String("key", nsgrWithName(key)),
}
if b.err != nil {
attrs = append(attrs, attribute.String("error", b.err.Error()))
+13
View File
@@ -79,6 +79,11 @@ func ReadSearchID(x *resourcepb.ResourceKey, v string) error {
// The namespace/group/resource
func NSGR(x *resourcepb.ResourceKey) string {
var sb strings.Builder
appendNSGR(&sb, x)
return sb.String()
}
func appendNSGR(sb *strings.Builder, x *resourcepb.ResourceKey) string {
if x.Namespace == "" {
sb.WriteString(clusterNamespace)
} else {
@@ -90,3 +95,11 @@ func NSGR(x *resourcepb.ResourceKey) string {
sb.WriteString(x.Resource)
return sb.String()
}
func nsgrWithName(x *resourcepb.ResourceKey) string {
var sb strings.Builder
appendNSGR(&sb, x)
sb.WriteString("/")
sb.WriteString(x.Name)
return sb.String()
}