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

Merging #2436 into master will decrease coverage by 0.01%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
plugin/storage/integration/integration.go 80.38% <0.00%> (ø)
cmd/collector/app/span_processor.go 100.00% <100.00%> (ø)
cmd/ingester/app/processor/span_processor.go 100.00% <100.00%> (ø)
cmd/query/app/querysvc/query_service.go 100.00% <100.00%> (ø)
plugin/storage/badger/spanstore/writer.go 97.53% <100.00%> (ø)
plugin/storage/cassandra/spanstore/writer.go 100.00% <100.00%> (ø)
plugin/storage/es/spanstore/writer.go 100.00% <100.00%> (ø)
plugin/storage/grpc/shared/grpc_client.go 85.96% <100.00%> (ø)
plugin/storage/grpc/shared/grpc_server.go 76.47% <100.00%> (ø)
plugin/storage/kafka/writer.go 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c1deaf...af279ff. Read the comment docs.

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 <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@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 <[email protected]>

* fmt

Signed-off-by: Yuri Shkuro <[email protected]>

* Regen mocks and fix tests

Signed-off-by: Yuri Shkuro <[email protected]>

* Remove context field

Signed-off-by: Yuri Shkuro <[email protected]>

* add TODOs

Signed-off-by: Yuri Shkuro <[email protected]>

* remove Context field

Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: albertteoh <[email protected]>
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