-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Upgrage storage integration test to storage v2 API #6388
base: main
Are you sure you want to change the base?
Conversation
7b5ae83
to
b3a2eb1
Compare
Hello @yurishkuro, please review this implementation. |
I need to go through it more carefully but on a brief scan looks very much in the right direction. |
b3a2eb1
to
3908c5a
Compare
spans := modelSpansFromOtelTrace(otelTrace) | ||
for _, span := range spans { | ||
traceId := span.TraceID.ToOTELTraceID() | ||
if _, exists := tracesByID[traceId]; !exists { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you went into opposite direction - not trusting the contact of the iterator. The contract says that if a trace is split into more than one chunk then those chunks will be consecutive. That means you can re-assemble the model traces without maintaining a map, simply by keeping track of the last seen trace ID.
jaeger/storage_v2/tracestore/reader.go
Lines 22 to 24 in 42a20f0
// Chunking requirements: | |
// - A single ptrace.Traces chunk MUST NOT contain spans from multiple traces. | |
// - Large traces MAY be split across multiple, *consecutive* ptrace.Traces chunks. |
// Chunking requirements:
// - A single ptrace.Traces chunk MUST NOT contain spans from multiple traces.
// - Large traces MAY be split across multiple, *consecutive* ptrace.Traces chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use AggregateTraces
function from internal/jptrace/aggregator.go
together with iter.CollectWithErrors
:
traces := iter.iter.CollectWithErrors(jptrace.AggregateTraces(seqTrace))
The traces
is now a plain slice where each element is a complete trace that can be passed to modelSpansFromOtelTrace
// PTracesSeq2ToModel consumes an otel trace iterator and returns a jaeger model trace. | ||
// | ||
// When necessary, it groups chunks of traces into one single trace | ||
func PTracesSeq2ToModel(seqTrace iter.Seq2[[]ptrace.Traces, error]) ([]*model.Trace, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a test
@@ -213,11 +217,14 @@ func (s *StorageIntegration) testGetLargeSpan(t *testing.T) { | |||
|
|||
expected := s.writeLargeTraceWithDuplicateSpanIds(t) | |||
expectedTraceID := expected.Spans[0].TraceID | |||
expectedOtelTraceID := expectedTraceID.ToOTELTraceID() | |||
|
|||
var actual *model.Trace | |||
found := s.waitForCondition(t, func(_ *testing.T) bool { | |||
var err error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var err error |
@@ -286,14 +293,17 @@ func (s *StorageIntegration) testGetTrace(t *testing.T) { | |||
|
|||
expected := s.loadParseAndWriteExampleTrace(t) | |||
expectedTraceID := expected.Spans[0].TraceID | |||
expectedOtelTraceID := expectedTraceID.ToOTELTraceID() | |||
|
|||
var actual *model.Trace | |||
found := s.waitForCondition(t, func(t *testing.T) bool { | |||
var err error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var err error |
6d7366b
to
7ccf5f7
Compare
`StorageIntegrationV2` supports v2 storage api interfaces as StorageIntegration still supports v1 api Provide a function for extracting flat array of spans from otel traces Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
Accept combination of change in the file Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
…ckend Signed-off-by: Ebenezer <[email protected]> Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
…2ToModel` Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
7ccf5f7
to
1760562
Compare
sorry, I don't follow what recent changes are you making, the code looks the same as before. |
Apologies, I haven't been able to make changes yet. I made a mistake trying to update this branch with |
make sure to hit Update Branch button before continuing. |
// PTracesSeq2ToModel consumes an otel trace iterator and returns a jaeger model trace. | ||
// | ||
// When necessary, it groups chunks of traces into one single trace | ||
func PTracesSeq2ToModel(seqTrace iter.Seq2[[]ptrace.Traces, error]) ([]*model.Trace, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurishkuro can this file go in package jptrace
(potentially in translator.go
)? I could see this being reused in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels to me that it makes more sense in v1adapter than in jptrace
- the latter is only meant to deal with ptrace
domain objects.
Which problem is this PR solving?
Description of the changes
StorageIntegration
to align with v2 storage api while supporting v1 apiHow was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test