-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Inject trace context to grpc metadata #2870
Inject trace context to grpc metadata #2870
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2870 +/- ##
==========================================
+ Coverage 96.00% 96.03% +0.03%
==========================================
Files 229 229
Lines 9937 9941 +4
==========================================
+ Hits 9540 9547 +7
+ Misses 327 325 -2
+ Partials 70 69 -1
Continue to review full report at Codecov.
|
@@ -44,7 +44,7 @@ type archiveWriter struct { | |||
|
|||
// GetTrace takes a traceID and returns a Trace associated with that traceID from Archive Storage | |||
func (r *archiveReader) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { | |||
stream, err := r.client.GetArchiveTrace(upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{ | |||
stream, err := r.client.GetArchiveTrace(upgradeWithTraceContext(upgradeContextWithBearerToken(ctx)), &storage_v1.GetTraceRequest{ |
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.
I think it might be time to split the statement here, creating the context in one and using it in another.
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.
I've used a functional type with a composition function to refactor this part. I suppose it is fine now.
if !ok { | ||
md = metadata.New(nil) | ||
} else { | ||
md = md.Copy() |
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.
Why do you need a copy?
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.
Removed. I've checked it is unnecessary.
@@ -0,0 +1,51 @@ | |||
// Copyright (c) 2019 The Jaeger Authors. |
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.
oops?
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.
Changed to 2021
@@ -85,7 +121,7 @@ func (c *grpcClient) ArchiveSpanWriter() spanstore.Writer { | |||
|
|||
// GetTrace takes a traceID and returns a Trace associated with that traceID | |||
func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { | |||
stream, err := c.readerClient.GetTrace(upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{ | |||
stream, err := c.readerClient.GetTrace(upgradeWithTraceContext(upgradeContextWithBearerToken(ctx)), &storage_v1.GetTraceRequest{ |
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.
Given the number of places calling the two upgrade functions, it might be a good idea to combine both in another function, and use only this other function.
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.
Refactored in the same way
@jpkrohling Any idea why unit test failed? I don't think it is related to my latest modification Update: Seems not stable |
return ctx | ||
} | ||
|
||
if span := opentracing.SpanFromContext(ctx); span != 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.
This is not now RPCs are typically instrumented, you need to create a child span for each outbound request.
Also, there is a common lib https://opentracing.io/registry/go-grpc/ for gRPC instrumentation, can we use that instead of doing manual instrumentation?
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.
Yes. I agree with you that a child span should be created. But this is acutally a compromise here that I make use of the active span from the context.
The difficulty stems from the fact that go-plugin
does not support customized DialOption
which I have mentioned in the issue #2869.
The server-side code can use https://github.com/opentracing-contrib/go-grpc
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
0bdde89
to
4c600f6
Compare
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
15da37b
to
a559ebc
Compare
@jpkrohling @yurishkuro I've updated to the latest |
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.
- I see you're only changing grpc-client. Are there similar changes needed for the server?
- since there are no tests for tracing instrumentation of the plugin, could you try a manual test and post a screenshot of the trace?
plugin/storage/grpc/config/config.go
Outdated
@@ -16,11 +16,14 @@ package config | |||
|
|||
import ( | |||
"fmt" | |||
"github.com/opentracing/opentracing-go" |
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.
please move to the next group (I think make fmt
will do this automatically)
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.
Fixed
Signed-off-by: Megrez Lu <[email protected]>
The plugin developer can enable tracing while starting the plugin server. grpc.ServeWithGRPCServer(
store.NewAliyunSLSStore(&appConfig, logger),
func(options []googleGRPC.ServerOption) *googleGRPC.Server {
return plugin.DefaultGRPCServer([]googleGRPC.ServerOption{
googleGRPC.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(tracer)),
googleGRPC.StreamInterceptor(otgrpc.OpenTracingStreamServerInterceptor(tracer)),
})
},
) Do we need to make it a default option?
|
I don't know if there's a place to make this a default option, at minimum it would make sense to mention this in the plugin/README, and perhaps add to examples/memstore-plugin/main.go ? |
Signed-off-by: Megrez Lu <[email protected]>
Signed-off-by: Megrez Lu <[email protected]>
I've added a |
Should 1.23 wait for this one? |
Signed-off-by: Megrez Lu [email protected]
Which problem is this PR solving?
Resolve #2869
Short description of the changes
go-plugin
to1.4.2