Skip to content

Commit 7604dbb

Browse files
authored
feat(tracing): add OpenTelemetry tracing to SubscribeItem and SubscribeItems functions (#272)
On-behalf-of: @SAP [email protected] Signed-off-by: Angel Kafazov <[email protected]>
1 parent a949b38 commit 7604dbb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gateway/resolver/subscription.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88

99
"github.com/openmfp/golang-commons/sentry"
1010
"github.com/pkg/errors"
11+
"go.opentelemetry.io/otel"
12+
"go.opentelemetry.io/otel/attribute"
13+
"go.opentelemetry.io/otel/trace"
1114

1215
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1316

@@ -27,6 +30,8 @@ var (
2730

2831
func (r *Service) SubscribeItem(gvk schema.GroupVersionKind, scope v1.ResourceScope) graphql.FieldResolveFn {
2932
return func(p graphql.ResolveParams) (interface{}, error) {
33+
_, span := otel.Tracer("").Start(p.Context, "SubscribeItem", trace.WithAttributes(attribute.String("kind", gvk.Kind)))
34+
defer span.End()
3035
resultChannel := make(chan interface{})
3136
go r.runWatch(p, gvk, resultChannel, true, scope)
3237

@@ -36,6 +41,8 @@ func (r *Service) SubscribeItem(gvk schema.GroupVersionKind, scope v1.ResourceSc
3641

3742
func (r *Service) SubscribeItems(gvk schema.GroupVersionKind, scope v1.ResourceScope) graphql.FieldResolveFn {
3843
return func(p graphql.ResolveParams) (interface{}, error) {
44+
_, span := otel.Tracer("").Start(p.Context, "SubscribeItems", trace.WithAttributes(attribute.String("kind", gvk.Kind)))
45+
defer span.End()
3946
resultChannel := make(chan interface{})
4047
go r.runWatch(p, gvk, resultChannel, false, scope)
4148

0 commit comments

Comments
 (0)