-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix propagation issues for context in the new obsreport usage #625
Conversation
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.
Almost every receiver had an issue with passing the created Span or the Tags to the next component :(
_, span := obsreport.StartTraceDataReceiveOp( | ||
receiverCtx, jr.instanceName, collectorHTTPTransport) |
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.
Here it was a bug because the Span was not propagated to the consumer.
_, span := obsreport.StartTraceDataReceiveOp( | ||
ctx, jtr.instanceName, collectorTChannelTransport) |
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.
Here it was a bug because the Span was not propagated to the consumer.
_, span := obsreport.StartTraceDataReceiveOp( | ||
context.Background(), jr.instanceName, agentTransport) |
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.
Here it was a bug because the Span was not propagated to the consumer.
_, span := obsreport.StartTraceDataReceiveOp( | ||
ctx, jr.instanceName, grpcTransport) |
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.
Here it was a bug because the Span was not propagated to the consumer.
@@ -113,13 +114,17 @@ func (ocr *Receiver) processReceivedMetrics(longLivedRPCCtx context.Context, ni | |||
func (ocr *Receiver) sendToNextConsumer(longLivedRPCCtx context.Context, md consumerdata.MetricsData) { | |||
// Do not use longLivedRPCCtx to start the span so this trace ends right at this | |||
// function, and the span is not a child of any span from the stream context. | |||
_, span := obsreport.StartMetricsReceiveOp( | |||
tmpCtx := obsreport.StartMetricsReceiveOp( | |||
context.Background(), | |||
ocr.instanceName, | |||
receiverTransport) |
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.
Here it was a bug because the Span was not propagated to the consumer.
@@ -160,7 +165,7 @@ func (ocr *Receiver) sendToNextConsumer(longLivedRPCCtx context.Context, traceda | |||
err = ocr.nextConsumer.ConsumeTraceData(ctx, *tracedata) |
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.
Bug: We did not pass the tags from the longLivedRPCCtx to the consumer so metrics recorded in the producer/exporter will not have them.
Codecov Report
@@ Coverage Diff @@
## master #625 +/- ##
==========================================
- Coverage 75.27% 75.26% -0.01%
==========================================
Files 139 139
Lines 9674 9672 -2
==========================================
- Hits 7282 7280 -2
Misses 2072 2072
Partials 320 320
Continue to review full report at Codecov.
|
Signed-off-by: Bogdan Drutu <[email protected]>
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.
Will you have some time to do a quick presentation on how to do the context propagation correctly? I have no idea how this code works and I suspect there may be others in the team who may benefit from what you can tell.
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.
Thanks for catching my bugs @bogdandrutu
@@ -75,7 +75,7 @@ func StartTraceDataReceiveOp( | |||
operationCtx context.Context, | |||
receiver string, | |||
transport string, | |||
) (context.Context, *trace.Span) { |
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.
Ok, it makes sense: the few cases that one may want to add something to the span can be done by extracting it from context.
|
||
// TODO: We should offer a version of StartTraceDataReceiveOp that starts the Span | ||
// with as root, and links to the longLived context. | ||
ctx := trace.NewContext(longLivedRPCCtx, trace.FromContext(tmpCtx)) |
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.
Thanks, I wasn't aware that this is the correct way to propagate the tags from parent while still having a trace for the individual operation. I will work on getting the TODO done.
No description provided.