Skip to content

Commit

Permalink
Fix Usages
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Feb 23, 2025
1 parent b730991 commit 049231b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cmd/jaeger/internal/integration/trace_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"math"
"strings"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"
"go.uber.org/zap"
"google.golang.org/grpc"
Expand Down Expand Up @@ -138,7 +137,7 @@ func (r *traceReader) FindTraces(
func (*traceReader) FindTraceIDs(
_ context.Context,
_ tracestore.TraceQueryParams,
) iter.Seq2[[]pcommon.TraceID, error] {
) iter.Seq2[tracestore.FindTraceIDsResponse, error] {
panic("not implemented")
}

Expand Down
12 changes: 8 additions & 4 deletions internal/storage/v2/v1adapter/tracereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,22 @@ func (tr *TraceReader) FindTraces(
func (tr *TraceReader) FindTraceIDs(
ctx context.Context,
query tracestore.TraceQueryParams,
) iter.Seq2[[]pcommon.TraceID, error] {
return func(yield func([]pcommon.TraceID, error) bool) {
) iter.Seq2[tracestore.FindTraceIDsResponse, error] {
return func(yield func(tracestore.FindTraceIDsResponse, error) bool) {
traceIDs, err := tr.spanReader.FindTraceIDs(ctx, query.ToSpanStoreQueryParameters())
if err != nil {
yield(nil, err)
yield(tracestore.FindTraceIDsResponse{
TraceIDs: nil,
}, err)
return
}
otelIDs := make([]pcommon.TraceID, 0, len(traceIDs))
for _, traceID := range traceIDs {
otelIDs = append(otelIDs, FromV1TraceID(traceID))
}
yield(otelIDs, nil)
yield(tracestore.FindTraceIDsResponse{
TraceIDs: otelIDs,
}, nil)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/storage/v2/v1adapter/tracereader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func TestTraceReader_FindTraceIDsDelegatesResponse(t *testing.T) {
traceReader := &TraceReader{
spanReader: sr,
}
traceIDs, err := jiter.FlattenWithErrors(traceReader.FindTraceIDs(
traceIDs, err := jiter.CollectWithErrors(traceReader.FindTraceIDs(
context.Background(),
tracestore.TraceQueryParams{
ServiceName: "service",
Expand Down
7 changes: 4 additions & 3 deletions internal/storage/v2/v1adapter/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/jaegertracing/jaeger-idl/model/v1"
"github.com/jaegertracing/jaeger/internal/jptrace"
"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore"
)

// V1BatchesFromTraces converts OpenTelemetry traces (ptrace.Traces)
Expand Down Expand Up @@ -62,17 +63,17 @@ func V1TracesFromSeq2(otelSeq iter.Seq2[[]ptrace.Traces, error]) ([]*model.Trace
return jaegerTraces, nil
}

func V1TraceIDsFromSeq2(traceIDsIter iter.Seq2[[]pcommon.TraceID, error]) ([]model.TraceID, error) {
func V1TraceIDsFromSeq2(traceIDsIter iter.Seq2[tracestore.FindTraceIDsResponse, error]) ([]model.TraceID, error) {
var (
iterErr error
modelTraceIDs []model.TraceID
)
traceIDsIter(func(traceIDs []pcommon.TraceID, err error) bool {
traceIDsIter(func(traceIDsResponse tracestore.FindTraceIDsResponse, err error) bool {
if err != nil {
iterErr = err
return false
}
for _, traceID := range traceIDs {
for _, traceID := range traceIDsResponse.TraceIDs {
modelTraceIDs = append(modelTraceIDs, ToV1TraceID(traceID))
}
return true
Expand Down
23 changes: 14 additions & 9 deletions internal/storage/v2/v1adapter/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/jaegertracing/jaeger-idl/model/v1"
"github.com/jaegertracing/jaeger/internal/jptrace"
"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore"
)

func TestProtoFromTraces_AddsWarnings(t *testing.T) {
Expand Down Expand Up @@ -287,30 +288,34 @@ func TestV1TraceToOtelTrace_ReturnEmptyOtelTrace(t *testing.T) {
func TestV1TraceIDsFromSeq2(t *testing.T) {
testCases := []struct {
name string
seqTraceIDs iter.Seq2[[]pcommon.TraceID, error]
seqTraceIDs iter.Seq2[tracestore.FindTraceIDsResponse, error]
expectedIDs []model.TraceID
expectedError error
}{
{
name: "empty sequence",
seqTraceIDs: func(func([]pcommon.TraceID, error) bool) {},
seqTraceIDs: func(func(tracestore.FindTraceIDsResponse, error) bool) {},
expectedIDs: nil,
expectedError: nil,
},
{
name: "sequence with error",
seqTraceIDs: func(yield func([]pcommon.TraceID, error) bool) {
yield(nil, assert.AnError)
seqTraceIDs: func(yield func(tracestore.FindTraceIDsResponse, error) bool) {
yield(tracestore.FindTraceIDsResponse{
TraceIDs: nil,
}, assert.AnError)
},
expectedIDs: nil,
expectedError: assert.AnError,
},
{
name: "sequence with one chunk of trace IDs",
seqTraceIDs: func(yield func([]pcommon.TraceID, error) bool) {
seqTraceIDs: func(yield func(tracestore.FindTraceIDsResponse, error) bool) {
traceID1 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3})
traceID2 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5})
yield([]pcommon.TraceID{traceID1, traceID2}, nil)
yield(tracestore.FindTraceIDsResponse{
TraceIDs: []pcommon.TraceID{traceID1, traceID2},
}, nil)
},
expectedIDs: []model.TraceID{
model.NewTraceID(2, 3),
Expand All @@ -320,12 +325,12 @@ func TestV1TraceIDsFromSeq2(t *testing.T) {
},
{
name: "sequence with multiple chunks of trace IDs",
seqTraceIDs: func(yield func([]pcommon.TraceID, error) bool) {
seqTraceIDs: func(yield func(tracestore.FindTraceIDsResponse, error) bool) {
traceID1 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3})
traceID2 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5})
traceID3 := pcommon.TraceID([16]byte{0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7})
yield([]pcommon.TraceID{traceID1}, nil)
yield([]pcommon.TraceID{traceID2, traceID3}, nil)
yield(tracestore.FindTraceIDsResponse{TraceIDs: []pcommon.TraceID{traceID1}}, nil)
yield(tracestore.FindTraceIDsResponse{TraceIDs: []pcommon.TraceID{traceID2, traceID3}}, nil)
},
expectedIDs: []model.TraceID{
model.NewTraceID(2, 3),
Expand Down

0 comments on commit 049231b

Please sign in to comment.