-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add context.Context to WriteSpan #2436
Conversation
@@ -140,7 +141,7 @@ func (sp *spanProcessor) saveSpan(span *model.Span) { | |||
} | |||
|
|||
startTime := time.Now() | |||
if err := sp.spanWriter.WriteSpan(span); err != nil { | |||
if err := sp.spanWriter.WriteSpan(context.TODO(), span); err != 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.
Using TODO here because there is a design issue with spanProcessor, which should be managing the context earlier
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.
Yep, for complete context propagation context needs to be added to the processor.SpanProcessor
interface, we can do that in a follow up PR.
if err != nil { | ||
return fmt.Errorf("cannot unmarshall byte array into span: %w", err) | ||
} | ||
return s.writer.WriteSpan(mSpan) | ||
return s.writer.WriteSpan(context.TODO(), 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.
Using TODO here because KafkaSpanProcessor should be managing the context earlier.
batch := model.Batch{ | ||
Spans: []*model.Span{span}, | ||
Process: span.Process, | ||
} | ||
traces := jaegertranslator.ProtoBatchToInternalTraces(batch) | ||
// TODO what does w.ctx represent? |
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.
@pavolloffay can we get rid of w.ctx
?
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 because of the metrics, check the line 38, Since the context is now propagated we should modify it here.
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.
If I use the ctx
arg in L93, I don't see where else w.ctx
would be used. Should w.ctx
be removed completely then? Or do we need to enrich ctx
here similar to L38 and L40?
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 the w.ctx
can be removed and instead the context can be modified in the write method.
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, I made the changes, PTAL. But I think this needs to be revisited because it looks like a significant performance hit due to multiple memory allocations just to add some static labels. There should be a cheaper way of doing it, e.g. attaching a mutable structure to the Context at the start.
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.
Anyways this kafka receiver will go away and we will use the one from OTEL upsteream.
d650b81
to
0b05d47
Compare
type Writer interface { | ||
WriteSpan(span *model.Span) error | ||
} | ||
|
||
var ( |
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.
constants must come before types
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2436 +/- ##
==========================================
- Coverage 95.59% 95.58% -0.02%
==========================================
Files 208 208
Lines 10681 10679 -2
==========================================
- Hits 10211 10207 -4
- Misses 399 400 +1
- Partials 71 72 +1 ☔ View full report in Codecov by Sentry. |
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.
The context in the OTEL kafka has to be modified.
batch := model.Batch{ | ||
Spans: []*model.Span{span}, | ||
Process: span.Process, | ||
} | ||
traces := jaegertranslator.ProtoBatchToInternalTraces(batch) | ||
// TODO what does w.ctx represent? |
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 because of the metrics, check the line 38, Since the context is now propagated we should modify it here.
@@ -140,7 +141,7 @@ func (sp *spanProcessor) saveSpan(span *model.Span) { | |||
} | |||
|
|||
startTime := time.Now() | |||
if err := sp.spanWriter.WriteSpan(span); err != nil { | |||
if err := sp.spanWriter.WriteSpan(context.TODO(), span); err != 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.
Yep, for complete context propagation context needs to be added to the processor.SpanProcessor
interface, we can do that in a follow up PR.
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
0b05d47
to
ad4419e
Compare
Signed-off-by: Yuri Shkuro <github@ysh.us>
* Add context.Context to WriteSpan Signed-off-by: Yuri Shkuro <github@ysh.us> * fmt Signed-off-by: Yuri Shkuro <github@ysh.us> * Regen mocks and fix tests Signed-off-by: Yuri Shkuro <github@ysh.us> * Remove context field Signed-off-by: Yuri Shkuro <github@ysh.us> * add TODOs Signed-off-by: Yuri Shkuro <github@ysh.us> * remove Context field Signed-off-by: Yuri Shkuro <github@ysh.us> Signed-off-by: albertteoh <albert.teoh@logz.io>
No description provided.