Skip to content
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

Merged
merged 6 commits into from
Sep 2, 2020

Conversation

yurishkuro
Copy link
Member

No description provided.

@yurishkuro yurishkuro requested a review from a team as a code owner August 31, 2020 00:26
@@ -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 {
Copy link
Member Author

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

Copy link
Member

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)
Copy link
Member Author

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?
Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

type Writer interface {
WriteSpan(span *model.Span) error
}

var (
Copy link
Member Author

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
Copy link

codecov bot commented Aug 31, 2020

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.58%. Comparing base (0c1deaf) to head (af279ff).

Files with missing lines Patch % Lines
plugin/storage/integration/integration.go 0.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@pavolloffay pavolloffay left a 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?
Copy link
Member

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 {
Copy link
Member

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.

plugin/storage/es/spanstore/writer.go Outdated Show resolved Hide resolved
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
@pavolloffay pavolloffay merged commit 8630a31 into jaegertracing:master Sep 2, 2020
@yurishkuro yurishkuro deleted the writer-context branch September 2, 2020 14:10
albertteoh pushed a commit to albertteoh/jaeger that referenced this pull request Sep 3, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants