Include resource name in the event. (#107185)
This commit is contained in:
@@ -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()))
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user