forked from jaegertracing/jaeger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor collector pipeline to allow v1/v2 data model (jaegertracing#…
…6484) ## Which problem is this PR solving? - Part of jaegertracing#6474 ## Description of the changes - Extend SpanProcessor interface to carry either v1 or v2 spans ## How was this change tested? - CI --------- Signed-off-by: Yuri Shkuro <[email protected]> Signed-off-by: adityachopra29 <[email protected]>
- Loading branch information
1 parent
9b4467a
commit ad19190
Showing
15 changed files
with
288 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 | ||
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 | ||
} | ||
|
||
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 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 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.