Skip to content

Commit

Permalink
Return Timestamps From GetTraceIDs
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 84212d2 commit 6d6e056
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 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.GetTraceParams, error] {
panic("not implemented")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/storage/v2/api/tracestore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Reader interface {
// of matching trace IDs. This is useful in some contexts, such as batch jobs, where a
// large list of trace IDs may be queried first and then the full traces are loaded
// in batches.
FindTraceIDs(ctx context.Context, query TraceQueryParams) iter.Seq2[[]pcommon.TraceID, error]
FindTraceIDs(ctx context.Context, query TraceQueryParams) iter.Seq2[[]GetTraceParams, error]
}

// GetTraceParams contains single-trace parameters for a GetTraces request.
Expand Down
13 changes: 7 additions & 6 deletions internal/storage/v2/v1adapter/tracereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"iter"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"

"github.com/jaegertracing/jaeger-idl/model/v1"
Expand Down Expand Up @@ -113,18 +112,20 @@ 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.GetTraceParams, error] {
return func(yield func([]tracestore.GetTraceParams, error) bool) {

Check warning on line 116 in internal/storage/v2/v1adapter/tracereader.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/tracereader.go#L115-L116

Added lines #L115 - L116 were not covered by tests
traceIDs, err := tr.spanReader.FindTraceIDs(ctx, query.ToSpanStoreQueryParameters())
if err != nil {
yield(nil, err)
return
}
otelIDs := make([]pcommon.TraceID, 0, len(traceIDs))
getTraceParams := make([]tracestore.GetTraceParams, 0, len(traceIDs))

Check warning on line 122 in internal/storage/v2/v1adapter/tracereader.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/tracereader.go#L122

Added line #L122 was not covered by tests
for _, traceID := range traceIDs {
otelIDs = append(otelIDs, FromV1TraceID(traceID))
getTraceParams = append(getTraceParams, tracestore.GetTraceParams{
TraceID: FromV1TraceID(traceID),
})

Check warning on line 126 in internal/storage/v2/v1adapter/tracereader.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/tracereader.go#L124-L126

Added lines #L124 - L126 were not covered by tests
}
yield(otelIDs, nil)
yield(getTraceParams, nil)

Check warning on line 128 in internal/storage/v2/v1adapter/tracereader.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/tracereader.go#L128

Added line #L128 was not covered by tests
}
}

Expand Down
9 changes: 5 additions & 4 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,18 +63,18 @@ 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.GetTraceParams, error]) ([]model.TraceID, error) {

Check warning on line 66 in internal/storage/v2/v1adapter/translator.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/translator.go#L66

Added line #L66 was not covered by tests
var (
iterErr error
modelTraceIDs []model.TraceID
)
traceIDsIter(func(traceIDs []pcommon.TraceID, err error) bool {
traceIDsIter(func(getTraceParams []tracestore.GetTraceParams, err error) bool {

Check warning on line 71 in internal/storage/v2/v1adapter/translator.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/translator.go#L71

Added line #L71 was not covered by tests
if err != nil {
iterErr = err
return false
}
for _, traceID := range traceIDs {
modelTraceIDs = append(modelTraceIDs, ToV1TraceID(traceID))
for _, param := range getTraceParams {
modelTraceIDs = append(modelTraceIDs, ToV1TraceID(param.TraceID))

Check warning on line 77 in internal/storage/v2/v1adapter/translator.go

View check run for this annotation

Codecov / codecov/patch

internal/storage/v2/v1adapter/translator.go#L76-L77

Added lines #L76 - L77 were not covered by tests
}
return true
})
Expand Down

0 comments on commit 6d6e056

Please sign in to comment.