-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Refactor collector pipeline to allow v1/v2 data model #6484
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
yurishkuro
merged 8 commits into
jaegertracing:main
from
yurishkuro:pipeline-add-v2-model
Jan 5, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a63cd19
Refactor collector pipeline to allow v1/v2 data model
yurishkuro 8ddd301
fix
yurishkuro 66f17e3
fix
yurishkuro 7d45b26
Merge branch 'main' into pipeline-add-v2-model
yurishkuro 4a370fb
delint
yurishkuro 85d9c20
fix
yurishkuro 809abdb
fix
yurishkuro 2df3d4e
Merge branch 'main' into pipeline-add-v2-model
yurishkuro 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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2020 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package processor | ||
|
||
import ( | ||
"io" | ||
|
||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
) | ||
|
||
var ( | ||
_ Batch = (*SpansV1)(nil) | ||
_ Batch = (*SpansV2)(nil) | ||
) | ||
|
||
// Batch is a batch of spans passed to the processor. | ||
type Batch interface { | ||
// GetSpans delegates to the appropriate function based on the data model version. | ||
GetSpans(v1 func(spans []*model.Span), v2 func(traces ptrace.Traces)) | ||
|
||
GetSpanFormat() SpanFormat | ||
GetInboundTransport() InboundTransport | ||
GetTenant() string | ||
} | ||
|
||
// SpanProcessor handles spans | ||
mahadzaryab1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type SpanProcessor interface { | ||
// ProcessSpans processes spans and return with either a list of true/false success or an error | ||
ProcessSpans(spans Batch) ([]bool, error) | ||
io.Closer | ||
} | ||
|
||
type Details struct { | ||
SpanFormat SpanFormat | ||
InboundTransport InboundTransport | ||
Tenant string | ||
} | ||
|
||
// Spans is a batch of spans passed to the processor. | ||
type SpansV1 struct { | ||
Spans []*model.Span | ||
Details | ||
} | ||
|
||
type SpansV2 struct { | ||
Traces ptrace.Traces | ||
Details | ||
} | ||
mahadzaryab1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
func (s SpansV1) GetSpans(v1 func([]*model.Span), _ func(ptrace.Traces)) { | ||
v1(s.Spans) | ||
} | ||
|
||
func (s SpansV2) GetSpans(_ func([]*model.Span), v2 func(ptrace.Traces)) { | ||
v2(s.Traces) | ||
} | ||
|
||
func (d Details) GetSpanFormat() SpanFormat { | ||
return d.SpanFormat | ||
} | ||
|
||
func (d Details) GetInboundTransport() InboundTransport { | ||
return d.InboundTransport | ||
} | ||
|
||
func (d Details) GetTenant() string { | ||
return d.Tenant | ||
} |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package processor | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
) | ||
|
||
func TestDetails(t *testing.T) { | ||
d := Details{ | ||
SpanFormat: JaegerSpanFormat, | ||
InboundTransport: GRPCTransport, | ||
Tenant: "tenant", | ||
} | ||
assert.Equal(t, JaegerSpanFormat, d.GetSpanFormat()) | ||
assert.Equal(t, GRPCTransport, d.GetInboundTransport()) | ||
assert.Equal(t, "tenant", d.GetTenant()) | ||
} | ||
|
||
func TestSpansV1(t *testing.T) { | ||
s := SpansV1{ | ||
Spans: []*model.Span{{}}, | ||
Details: Details{ | ||
SpanFormat: JaegerSpanFormat, | ||
InboundTransport: GRPCTransport, | ||
Tenant: "tenant", | ||
}, | ||
} | ||
var spans []*model.Span | ||
s.GetSpans(func(s []*model.Span) { | ||
spans = s | ||
}, func(_ ptrace.Traces) { | ||
panic("not implemented") | ||
}) | ||
assert.Equal(t, []*model.Span{{}}, spans) | ||
assert.Equal(t, JaegerSpanFormat, s.GetSpanFormat()) | ||
assert.Equal(t, GRPCTransport, s.GetInboundTransport()) | ||
assert.Equal(t, "tenant", s.GetTenant()) | ||
} | ||
|
||
func TestSpansV2(t *testing.T) { | ||
s := SpansV2{ | ||
Traces: ptrace.NewTraces(), | ||
Details: Details{ | ||
SpanFormat: JaegerSpanFormat, | ||
InboundTransport: GRPCTransport, | ||
Tenant: "tenant", | ||
}, | ||
} | ||
var traces ptrace.Traces | ||
s.GetSpans(func(_ []*model.Span) { | ||
panic("not implemented") | ||
}, func(t ptrace.Traces) { | ||
traces = t | ||
}) | ||
assert.Equal(t, ptrace.NewTraces(), traces) | ||
assert.Equal(t, JaegerSpanFormat, s.GetSpanFormat()) | ||
assert.Equal(t, GRPCTransport, s.GetInboundTransport()) | ||
assert.Equal(t, "tenant", s.GetTenant()) | ||
} |
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.
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.