Change:
Feedback originally provided on slack: It would be helpful to have additional fields on APIServer spans. This is the current set of attributes we provide: It would be helpful to add: group, version, namespace, name, and subresource, if possible. Part of
/sig instrumentation /sig apimachinery /priority important-longterm cc /triage accepted
The label(s) cannot be applied, because the repository doesn't have them. <detailsIn response to : /sig instrumentation /sig apimachinery /priority important-longterm cc /triage accepted Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/sig api-machinery
/assign

Discussion:
return "unknown" } <ins> // lazyAPIGroup implements String() string and it will // lazily get Group from request info. type lazyAPIGroup struct { req *http.Request } func (lazy *lazyAPIGroup) String() string { if lazy.req != nil { ctx := lazy.req.Context() requestInfo, ok := apirequest.RequestInfoFrom(ctx) if ok { return requestInfo.APIGroup } } return "unknown" } // lazyAPIVersion implements String() string and it will // lazily get Group from request info. type lazyAPIVersion struct { req *http.Request } func (lazy *lazyAPIVersion) String() string { if lazy.req != nil { ctx := lazy.req.Context() requestInfo, ok := apirequest.RequestInfoFrom(ctx) if ok { return requestInfo.APIVersion } } return "unknown" } // lazyName implements String() string and it will // lazily get Group from request info. type lazyName struct { req *http.Request } func (lazy *lazyName) String() string { if lazy.req != nil { ctx := lazy.req.Context() requestInfo, ok := apirequest.RequestInfoFrom(ctx) if ok { return requestInfo.Name } } return "unknown" } // lazySubresource implements String() string and it will // lazily get Group from request info. type lazySubresource struct { req *http.Request } func (lazy *lazySubresource) String() string { if lazy.req != nil { ctx := lazy.req.Context() requestInfo, ok := apirequest.RequestInfoFrom(ctx) if ok { return requestInfo.Subresource } } return "unknown" } // lazyNamespace implements String() string and it will // lazily get Group from request info. type lazyNamespace struct { req *http.Request } func (lazy *lazyNamespace) String() string { if lazy.req != nil { ctx := lazy.req.Context() requestInfo, ok := apirequest.RequestInfoFrom(ctx) if ok { return requestInfo.Namespace } } return "unknown" } </ins> // lazyAuditID implements Stringer interface to lazily retrieve // the audit ID associated with the request. type lazyAuditID struct {

assert.Equal(t, "WATCH", fmt.Sprintf("%v", verbWithReq)) } <ins> func TestLazyApiGroup(t *testing.T) { assert.Equal(t, "unknown", fmt.Sprintf("%v", &lazyAPIGroup{})) scopeWithEmptyReq := &lazyAPIGroup{&http.Request{}} assert.Equal(t, "unknown", fmt.Sprintf("%v", scopeWithEmptyReq)) req := &http.Request{} ctx := request.WithRequestInfo(context.TODO(), &request.RequestInfo{APIGroup: "apps"}) scopeWithReq := &lazyAPIGroup{req: req.WithContext(ctx)} assert.Equal(t, "apps", fmt.Sprintf("%v", scopeWithReq)) } func TestLazyApiVersion(t *testing.T) { assert.Equal(t, "unknown", fmt.Sprintf("%v", &lazyAPIVersion{})) scopeWithEmptyReq := &lazyAPIVersion{&http.Request{}} assert.Equal(t, "unknown", fmt.Sprintf("%v", scopeWithEmptyReq)) req := &http.Request{} ctx := request.WithRequestInfo(context.TODO(), &request.RequestInfo{APIVersion: "v1"}) scopeWithReq := &lazyAPIVersion{req: req.WithContext(ctx)} assert.Equal(t, "v1", fmt.Sprintf("%v", scopeWithReq)) } func TestLazyName(t *testing.T) { assert.Equal(t, "unknown", fmt.Sprintf("%v", &lazyName{})) scopeWithEmptyReq := &lazyName{&http.Request{}} assert.Equal(t, "unknown", fmt.Sprintf("%v", scopeWithEmptyReq)) req := &http.Request{} ctx := request.WithRequestInfo(context.TODO(), &request.RequestInfo{Name: "jaeger-76d45d6876-vqp8t"}) scopeWithReq := &lazyName{req: req.WithContext(ctx)} assert.Equal(t, "jaeger-76d45d6876-vqp8t", fmt.Sprintf("%v", scopeWithReq)) } func TestLazySubresource(t *testing.T) { assert.Equal(t, "unknown", fmt.Sprintf("%v", &lazySubresource{})) scopeWithEmptyReq := &lazySubresource{&http.Request{}} assert.Equal(t, "unknown", fmt.Sprintf("%v", scopeWithEmptyReq)) req := &http.Request{} ctx := request.WithRequestInfo(context.TODO(), &request.RequestInfo{Subresource: "binding"}) scopeWithReq := &lazySubresource{req: req.WithContext(ctx)} assert.Equal(t, "binding", fmt.Sprintf("%v", scopeWithReq)) } func TestLazyNamespace(t *testing.T) { assert.Equal(t, "unknown", fmt.Sprintf("%v", &lazyNamespace{})) scopeWithEmptyReq := &lazyNamespace{&http.Request{}} assert.Equal(t, "unknown", fmt.Sprintf("%v", scopeWithEmptyReq)) req := &http.Request{} ctx := request.WithRequestInfo(context.TODO(), &request.RequestInfo{Namespace: "jaeger"}) scopeWithReq := &lazyNamespace{req: req.WithContext(ctx)} assert.Equal(t, "jaeger", fmt.Sprintf("%v", scopeWithReq)) } </ins> func TestLazyResource(t *testing.T) { assert.Equal(t, "unknown", fmt.Sprintf("%v", &lazyResource{}))

attribute.Stringer("accept", &lazyAccept{req: req}), attribute.Stringer("audit-id", &lazyAuditID{req: req}), attribute.Stringer("client", &lazyClientIP{req: req}), <ins> attribute.Stringer("api-group", &lazyAPIGroup{req: req}), attribute.Stringer("api-version", &lazyAPIVersion{req: req}), attribute.Stringer("name", &lazyName{req: req}), attribute.Stringer("subresource", &lazySubresource{req: req}), attribute.Stringer("namespace", &lazyNamespace{req: req}), </ins> attribute.String("protocol", req.Proto), attribute.Stringer("resource", &lazyResource{req: req}), attribute.Stringer("scope", &lazyScope{req: req}),