-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Pass Context through span processors #6534
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ const ( | |
minRequiredChange = 1.2 | ||
) | ||
|
||
var _ processor.SpanProcessor = (*spanProcessor)(nil) | ||
|
||
type spanProcessor struct { | ||
queue *queue.BoundedQueue[queueItem] | ||
otelExporter exporter.Traces | ||
|
@@ -240,18 +242,18 @@ func (sp *spanProcessor) countSpansInQueue(span *model.Span, _ string /* tenant | |
} | ||
|
||
// TODO pass Context | ||
func (sp *spanProcessor) ProcessSpans(batch processor.Batch) ([]bool, error) { | ||
func (sp *spanProcessor) ProcessSpans(ctx context.Context, batch processor.Batch) ([]bool, error) { | ||
// We call preProcessSpans on a batch, it's responsibility of implementation | ||
// to understand v1/v2 distinction. Jaeger itself does not use pre-processors. | ||
sp.preProcessSpans(batch) | ||
|
||
var batchOks []bool | ||
var batchErr error | ||
batch.GetSpans(func(spans []*model.Span) { | ||
batchOks, batchErr = sp.processSpans(batch, spans) | ||
batchOks, batchErr = sp.processSpans(ctx, batch, spans) | ||
}, func(traces ptrace.Traces) { | ||
// TODO verify if the context will survive all the way to the consumer threads. | ||
ctx := tenancy.WithTenant(context.Background(), batch.GetTenant()) | ||
ctx := tenancy.WithTenant(ctx, batch.GetTenant()) | ||
|
||
// the exporter will eventually call pushTraces from consumer threads. | ||
if err := sp.otelExporter.ConsumeTraces(ctx, traces); err != nil { | ||
|
@@ -266,7 +268,7 @@ func (sp *spanProcessor) ProcessSpans(batch processor.Batch) ([]bool, error) { | |
return batchOks, batchErr | ||
} | ||
|
||
func (sp *spanProcessor) processSpans(batch processor.Batch, spans []*model.Span) ([]bool, error) { | ||
func (sp *spanProcessor) processSpans(_ context.Context, batch processor.Batch, spans []*model.Span) ([]bool, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious - why are we passing the context in here if its not being used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better have it and not need it |
||
sp.metrics.BatchSize.Update(int64(len(spans))) | ||
retMe := make([]bool, len(spans)) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.