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

Upgrage storage integration test to storage v2 API #6388

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ekefan
Copy link

@ekefan ekefan commented Dec 19, 2024

Which problem is this PR solving?

Description of the changes

  • Incrementally swaps the fields of StorageIntegration to align with v2 storage api while supporting v1 api
  • Updates test functions accordingly to work with the updated fields

How was this change tested?

  • make test

Checklist

@ekefan ekefan requested a review from a team as a code owner December 19, 2024 13:41
@ekefan ekefan requested a review from albertteoh December 19, 2024 13:41
@ekefan ekefan force-pushed the upgrage-storage-integration branch 3 times, most recently from 7b5ae83 to b3a2eb1 Compare December 19, 2024 14:36
@ekefan
Copy link
Author

ekefan commented Dec 19, 2024

Hello @yurishkuro,

please review this implementation.

@yurishkuro
Copy link
Member

I need to go through it more carefully but on a brief scan looks very much in the right direction.

@yurishkuro yurishkuro added the changelog:ci Change related to continuous integration / testing label Dec 19, 2024
@ekefan ekefan force-pushed the upgrage-storage-integration branch from b3a2eb1 to 3908c5a Compare December 20, 2024 10:19
@ekefan ekefan requested a review from yurishkuro December 21, 2024 22:09
spans := modelSpansFromOtelTrace(otelTrace)
for _, span := range spans {
traceId := span.TraceID.ToOTELTraceID()
if _, exists := tracesByID[traceId]; !exists {
Copy link
Member

@yurishkuro yurishkuro Dec 21, 2024

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.

// 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.

Copy link
Member

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) {
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var err error

@ekefan ekefan force-pushed the upgrage-storage-integration branch 2 times, most recently from 6d7366b to 7ccf5f7 Compare December 23, 2024 17:02
`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]>
…2ToModel`

Signed-off-by: Emmanuel Emonueje Ebenezer <[email protected]>
@ekefan ekefan force-pushed the upgrage-storage-integration branch from 7ccf5f7 to 1760562 Compare December 23, 2024 17:06
@yurishkuro
Copy link
Member

sorry, I don't follow what recent changes are you making, the code looks the same as before.

@ekefan
Copy link
Author

ekefan commented Dec 24, 2024

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 upstream/main - I added commits, I didn't author. The recent push helped me fix that mistake so this branch can sync properly.

@yurishkuro
Copy link
Member

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) {
Copy link
Collaborator

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.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/storage changelog:ci Change related to continuous integration / testing v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade storage integration tests to Storage v2 API
3 participants