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

[refactor] Move internal TracesData type to package jptrace #6809

Merged
merged 5 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/jaeger/internal/integration/trace_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (*traceReader) FindTraceIDs(
}

type traceStream interface {
Recv() (*api_v3.TracesData, error)
Recv() (*jptrace.TracesData, error)
}

// consumeTraces reads the stream and calls yield for each chunk.
Expand Down
6 changes: 3 additions & 3 deletions cmd/query/app/apiv3/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (h *Handler) FindTraces(request *api_v3.FindTracesRequest, stream api_v3.Qu
func (h *Handler) internalFindTraces(
ctx context.Context,
request *api_v3.FindTracesRequest,
streamSend func(*api_v3.TracesData) error,
streamSend func(*jptrace.TracesData) error,
) error {
query := request.GetQuery()
if query == nil {
Expand Down Expand Up @@ -130,14 +130,14 @@ func (h *Handler) GetOperations(ctx context.Context, request *api_v3.GetOperatio

func receiveTraces(
seq iter.Seq2[[]ptrace.Traces, error],
sendFn func(*api_v3.TracesData) error,
sendFn func(*jptrace.TracesData) error,
) error {
for traces, err := range seq {
if err != nil {
return err
}
for _, trace := range traces {
tracesData := api_v3.TracesData(trace)
tracesData := jptrace.TracesData(trace)
if err := sendFn(&tracesData); err != nil {
return status.Error(codes.Internal,
fmt.Sprintf("failed to send response stream chunk to client: %v", err))
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/app/apiv3/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"google.golang.org/grpc/credentials/insecure"

"github.com/jaegertracing/jaeger/cmd/query/app/querysvc/v2/querysvc"
"github.com/jaegertracing/jaeger/internal/jptrace"
"github.com/jaegertracing/jaeger/internal/proto/api_v3"
dependencyStoreMocks "github.com/jaegertracing/jaeger/internal/storage/v2/api/depstore/mocks"
"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore"
Expand Down Expand Up @@ -204,7 +205,7 @@ func TestFindTracesSendError(t *testing.T) {
StartTimeMax: time.Now(),
},
},
/* streamSend= */ func(*api_v3.TracesData) error {
/* streamSend= */ func(*jptrace.TracesData) error {
return assert.AnError
},
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/app/apiv3/http_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/jaegertracing/jaeger-idl/model/v1"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc/v2/querysvc"
"github.com/jaegertracing/jaeger/internal/jiter"
"github.com/jaegertracing/jaeger/internal/jptrace"
"github.com/jaegertracing/jaeger/internal/proto/api_v3"
"github.com/jaegertracing/jaeger/internal/storage/v1/api/spanstore"
"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore"
Expand Down Expand Up @@ -113,7 +114,7 @@ func (h *HTTPGateway) tryParamError(w http.ResponseWriter, err error, paramName
}

func (h *HTTPGateway) returnTrace(td ptrace.Traces, w http.ResponseWriter) {
tracesData := api_v3.TracesData(td)
tracesData := jptrace.TracesData(td)
response := &api_v3.GRPCGatewayWrapper{
Result: &tracesData,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package api_v3
package jptrace

import (
"github.com/gogo/protobuf/jsonpb"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package api_v3
package jptrace

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/pdata/ptrace"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestTracesData(t *testing.T) {
Expand Down Expand Up @@ -57,7 +55,3 @@ func TestTracesData(t *testing.T) {
// Test String
assert.Equal(t, "*TracesData", td.String())
}

func TestMain(m *testing.M) {
testutils.VerifyGoLeaks(m)
}
28 changes: 14 additions & 14 deletions internal/proto/api_v3/query_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions scripts/makefiles/Protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ patch-api-v3:
.PHONY: proto-api-v3
proto-api-v3: patch-api-v3
$(call proto_compile, $(API_V3_PATH), $(API_V3_PATCHED), -I$(API_V3_PATCHED_DIR) -Iidl/opentelemetry-proto)
@echo "🏗️ replace TracesData with internal custom type"
$(SED) -i 's/v1.TracesData/TracesData/g' $(API_V3_PATH)/query_service.pb.go
@echo "🏗️ remove OTEL import because we're not using any other OTLP types"
@echo "🏗️ replace first instance of OTEL import with internal type"
$(SED) -i '0,/go.opentelemetry.io\/proto\/otlp\/trace\/v1/s/go.opentelemetry.io\/proto\/otlp\/trace\/v1/github.com\/jaegertracing\/jaeger\/internal\/jptrace/' $(API_V3_PATH)/query_service.pb.go
@echo "🏗️ remove all remaining OTEL imports because we're not using any other OTLP types"
$(SED) -i 's+^.*v1 "go.opentelemetry.io/proto/otlp/trace/v1".*$$++' $(API_V3_PATH)/query_service.pb.go
Loading