-
Notifications
You must be signed in to change notification settings - Fork 606
feat: trace watchable messages #7403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
11155f0
f66879c
2c0d0a1
4777f57
0af47d1
c620c6e
aa6b91b
2ad7399
f8d9f42
ff03fd5
bf58e55
c0846eb
1c5e52e
623406e
fd41925
8392b41
934dca2
fcadab2
afc0812
0480ec5
8b834a9
8ca0a2c
1be27d3
37107cd
f0ab998
8ee0225
0c2b09e
10fe843
3728b82
6c9d222
3d3340b
d4b7eb4
b59ff0d
c4b00c1
58ec2e2
3edaaf4
520a840
93f2ace
3bf3309
1e1322b
cd7fdd6
9836161
d96ac3a
be8f839
0c545cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ import ( | |
| resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3" | ||
| serverv3 "github.com/envoyproxy/go-control-plane/pkg/server/v3" | ||
| "github.com/telepresenceio/watchable" | ||
| "go.opentelemetry.io/otel" | ||
| "go.opentelemetry.io/otel/attribute" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/credentials" | ||
|
|
||
|
|
@@ -47,6 +49,8 @@ const ( | |
| rateLimitTLSCACertFilepath = "/certs/ca.crt" | ||
| ) | ||
|
|
||
| var tracer = otel.Tracer("envoy-gateway/global-rate-limit/runner") | ||
|
|
||
| type Config struct { | ||
| config.Server | ||
| XdsIR *message.XdsIR | ||
|
|
@@ -138,7 +142,20 @@ func (r *Runner) translateFromSubscription(ctx context.Context, c <-chan watchab | |
|
|
||
| message.HandleSubscription(message.Metadata{Runner: r.Name(), Message: message.XDSIRMessageName}, c, | ||
| func(update message.Update[string, *message.XdsIRWithContext], errChan chan error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar to the gateway-api runner can we add a parent span and 2 child span for |
||
| r.Logger.Info("received a notification") | ||
| parentCtx := context.Background() | ||
| if update.Value != nil && update.Value.Context != nil { | ||
| parentCtx = update.Value.Context | ||
| } | ||
| traceLogger := r.Logger.WithTrace(parentCtx) | ||
| traceLogger.Info("received a notification") | ||
|
|
||
| _, span := tracer.Start(parentCtx, "GlobalRateLimitRunner.translateFromSubscription") | ||
| defer span.End() | ||
|
|
||
| span.SetAttributes( | ||
| attribute.String("controller.key", update.Key), | ||
|
||
| attribute.Bool("update.delete", update.Delete), | ||
| ) | ||
|
|
||
| if update.Delete { | ||
| delete(rateLimitConfigsCache, update.Key) | ||
|
|
@@ -183,6 +200,9 @@ func (r *Runner) translate(xdsIR *ir.Xds) (*types.ResourceVersionTable, error) { | |
| } | ||
|
|
||
| func (r *Runner) updateSnapshot(ctx context.Context, resource types.XdsResources) { | ||
| _, span := tracer.Start(ctx, "GlobalRateLimitRunner.updateSnapshot") | ||
| defer span.End() | ||
|
|
||
| if r.cache == nil { | ||
| r.Logger.Error(nil, "failed to init the snapshot cache") | ||
| return | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| package translator | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "runtime" | ||
|
|
@@ -22,6 +23,7 @@ import ( | |
| matcherv3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" | ||
| resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3" | ||
| "github.com/envoyproxy/go-control-plane/pkg/wellknown" | ||
| "go.opentelemetry.io/otel" | ||
| protobuf "google.golang.org/protobuf/proto" | ||
| "google.golang.org/protobuf/types/known/anypb" | ||
| "google.golang.org/protobuf/types/known/wrapperspb" | ||
|
|
@@ -44,6 +46,8 @@ const ( | |
| emptyClusterName = "EmptyCluster" | ||
| ) | ||
|
|
||
| var tracer = otel.Tracer("envoy-gateway/xds/translator") | ||
|
||
|
|
||
| // The dummy cluster for TCP/UDP listeners that have no routes | ||
| var emptyRouteCluster = &clusterv3.Cluster{ | ||
| Name: emptyClusterName, | ||
|
|
@@ -94,7 +98,10 @@ type GlobalRateLimitSettings struct { | |
| } | ||
|
|
||
| // Translate translates the XDS IR into xDS resources | ||
| func (t *Translator) Translate(xdsIR *ir.Xds) (*types.ResourceVersionTable, error) { | ||
| func (t *Translator) Translate(xdsIR *ir.Xds, ctx context.Context) (*types.ResourceVersionTable, error) { | ||
| _, span := tracer.Start(ctx, "Translator.Translate") | ||
| defer span.End() | ||
|
|
||
| if xdsIR == nil { | ||
| return nil, errors.New("ir is nil") | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on just
translate? , since tracer already hasgateway-apirunner infoThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I did not get you, did you intend to name this event just
translate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah