diff --git a/Makefile.Protobuf.mk b/Makefile.Protobuf.mk index 141899672d7..6872efb3703 100644 --- a/Makefile.Protobuf.mk +++ b/Makefile.Protobuf.mk @@ -146,14 +146,17 @@ proto-otel: proto-prepare-otel $(foreach file,$(OTEL_PROTO_FILES), \ $(call proto_compile, proto-gen/otel, $(file), -I$(PATCHED_OTEL_PROTO_DIR), paths=source_relative)) -# Similar to 'proto-prepare-otel', this target modifies OTEL Protos by changing their Go package. -# This way the API v3 service uses official OTEL types like opentelemetry.proto.trace.v1.ResourceSpans -# which at runtime are mapped to our internal classes generated in proto-gen/otel by 'proto-otel' target. +# The API v3 service uses official OTEL type opentelemetry.proto.trace.v1.TracesData, +# which at runtime is mapped to a custom type in cmd/query/app/internal/api_v3/traces.go +# Unfortunately, gogoproto.customtype annotation cannot be applied to a method's return type, +# only to fields in a struct, so we use regex search/replace to swap it. +# Note that the .pb.go types must be generated into the same internal package $(API_V3_PATH) +# where a manually defined traces.go file is located. +API_V3_PATH=cmd/query/app/internal/api_v3 .PHONY: proto-api-v3 proto-api-v3: - $(call print_caption, Enriching OpenTelemetry Protos into $(PATCHED_OTEL_PROTO_DIR)) - rm -rf $(PATCHED_OTEL_PROTO_DIR)/* - cp -R idl/opentelemetry-proto/* $(PATCHED_OTEL_PROTO_DIR) - find $(PATCHED_OTEL_PROTO_DIR) -name "*.proto" | xargs -L 1 $(SED) -i 's+go.opentelemetry.io/proto/otlp+github.com/jaegertracing/jaeger/proto-gen/otel+g' - - $(call proto_compile, proto-gen/api_v3, idl/proto/api_v3/query_service.proto, -I$(PATCHED_OTEL_PROTO_DIR)) + $(call proto_compile, $(API_V3_PATH), idl/proto/api_v3/query_service.proto, -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" + $(SED) -i 's+^.*v1 "go.opentelemetry.io/proto/otlp/trace/v1".*$$++' $(API_V3_PATH)/query_service.pb.go diff --git a/cmd/all-in-one/all_in_one_test.go b/cmd/all-in-one/all_in_one_test.go index 70cca8d111b..b557dfcff22 100644 --- a/cmd/all-in-one/all_in_one_test.go +++ b/cmd/all-in-one/all_in_one_test.go @@ -31,7 +31,6 @@ import ( ui "github.com/jaegertracing/jaeger/model/json" "github.com/jaegertracing/jaeger/proto-gen/api_v2" - "github.com/jaegertracing/jaeger/proto-gen/api_v3" ) // These tests are only run when the environment variable TEST_MODE=integration is set. @@ -180,9 +179,11 @@ func getServicesAPIV3(t *testing.T) { require.NoError(t, err) body, _ := io.ReadAll(resp.Body) - var servicesResponse api_v3.GetServicesResponse + var servicesResponse struct { + Services []string + } err = json.Unmarshal(body, &servicesResponse) require.NoError(t, err) - require.Len(t, servicesResponse.GetServices(), 1) - assert.Contains(t, servicesResponse.GetServices()[0], "jaeger") + require.Len(t, servicesResponse.Services, 1) + assert.Contains(t, servicesResponse.Services[0], "jaeger") } diff --git a/cmd/query/app/apiv3/gateway_test.go b/cmd/query/app/apiv3/gateway_test.go index 24121ecfc3d..66b0e600f34 100644 --- a/cmd/query/app/apiv3/gateway_test.go +++ b/cmd/query/app/apiv3/gateway_test.go @@ -30,10 +30,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/jaegertracing/jaeger/cmd/query/app/internal/api_v3" "github.com/jaegertracing/jaeger/model" _ "github.com/jaegertracing/jaeger/pkg/gogocodec" // force gogo codec registration "github.com/jaegertracing/jaeger/pkg/tenancy" - "github.com/jaegertracing/jaeger/proto-gen/api_v3" "github.com/jaegertracing/jaeger/storage/spanstore" spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks" ) @@ -155,18 +155,7 @@ func (gw *testGateway) runGatewayGetOperations(t *testing.T) { func (gw *testGateway) runGatewayGetTrace(t *testing.T) { trace, traceID := makeTestTrace() gw.reader.On("GetTrace", matchContext, traceID).Return(trace, nil).Once() - - body, statusCode := gw.execRequest(t, "/api/v3/traces/"+traceID.String()) - require.Equal(t, http.StatusOK, statusCode, "response=%s", string(body)) - body = gw.verifySnapshot(t, body) - - var response api_v3.GRPCGatewayWrapper - parseResponse(t, body, &response) - - assert.Len(t, response.Result.ResourceSpans, 1) - assert.EqualValues(t, - bytesOfTraceID(t, traceID.High, traceID.Low), - response.Result.ResourceSpans[0].ScopeSpans[0].Spans[0].TraceID) + gw.getTracesAndVerify(t, "/api/v3/traces/"+traceID.String(), traceID) } func (gw *testGateway) runGatewayFindTraces(t *testing.T) { @@ -175,23 +164,18 @@ func (gw *testGateway) runGatewayFindTraces(t *testing.T) { gw.reader. On("FindTraces", matchContext, qp). Return([]*model.Trace{trace}, nil).Once() - body, statusCode := gw.execRequest(t, "/api/v3/traces?"+q.Encode()) + gw.getTracesAndVerify(t, "/api/v3/traces?"+q.Encode(), traceID) +} + +func (gw *testGateway) getTracesAndVerify(t *testing.T, url string, expectedTraceID model.TraceID) { + body, statusCode := gw.execRequest(t, url) require.Equal(t, http.StatusOK, statusCode, "response=%s", string(body)) body = gw.verifySnapshot(t, body) var response api_v3.GRPCGatewayWrapper parseResponse(t, body, &response) - - assert.Len(t, response.Result.ResourceSpans, 1) - assert.EqualValues(t, - bytesOfTraceID(t, traceID.High, traceID.Low), - response.Result.ResourceSpans[0].ScopeSpans[0].Spans[0].TraceID) -} - -func bytesOfTraceID(t *testing.T, high, low uint64) []byte { - traceID := model.NewTraceID(high, low) - buf := make([]byte, 16) - _, err := traceID.MarshalTo(buf) - require.NoError(t, err) - return buf + td := response.Result.ToTraces() + assert.EqualValues(t, 1, td.SpanCount()) + traceID := td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).TraceID() + assert.Equal(t, expectedTraceID.String(), traceID.String()) } diff --git a/cmd/query/app/apiv3/grpc_handler.go b/cmd/query/app/apiv3/grpc_handler.go index 12136b0a308..b71a72fe32b 100644 --- a/cmd/query/app/apiv3/grpc_handler.go +++ b/cmd/query/app/apiv3/grpc_handler.go @@ -22,9 +22,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/jaegertracing/jaeger/cmd/query/app/internal/api_v3" "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" "github.com/jaegertracing/jaeger/model" - "github.com/jaegertracing/jaeger/proto-gen/api_v3" "github.com/jaegertracing/jaeger/storage/spanstore" ) @@ -33,6 +33,7 @@ type Handler struct { QueryService *querysvc.QueryService } +// remove me var _ api_v3.QueryServiceServer = (*Handler)(nil) // GetTrace implements api_v3.QueryServiceServer's GetTrace @@ -46,13 +47,12 @@ func (h *Handler) GetTrace(request *api_v3.GetTraceRequest, stream api_v3.QueryS if err != nil { return fmt.Errorf("cannot retrieve trace: %w", err) } - resourceSpans, err := modelToOTLP(trace.GetSpans()) + td, err := modelToOTLP(trace.GetSpans()) if err != nil { return err } - return stream.Send(&api_v3.SpansResponseChunk{ - ResourceSpans: resourceSpans, - }) + tracesData := api_v3.TracesData(td) + return stream.Send(&tracesData) } // FindTraces implements api_v3.QueryServiceServer's FindTraces @@ -106,13 +106,12 @@ func (h *Handler) FindTraces(request *api_v3.FindTracesRequest, stream api_v3.Qu return err } for _, t := range traces { - resourceSpans, err := modelToOTLP(t.GetSpans()) + td, err := modelToOTLP(t.GetSpans()) if err != nil { return err } - stream.Send(&api_v3.SpansResponseChunk{ - ResourceSpans: resourceSpans, - }) + tracesData := api_v3.TracesData(td) + stream.Send(&tracesData) } return nil } diff --git a/cmd/query/app/apiv3/grpc_handler_test.go b/cmd/query/app/apiv3/grpc_handler_test.go index 58fd6617d0c..2271abb382a 100644 --- a/cmd/query/app/apiv3/grpc_handler_test.go +++ b/cmd/query/app/apiv3/grpc_handler_test.go @@ -27,10 +27,10 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "github.com/jaegertracing/jaeger/cmd/query/app/internal/api_v3" "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" "github.com/jaegertracing/jaeger/model" _ "github.com/jaegertracing/jaeger/pkg/gogocodec" // force gogo codec registration - "github.com/jaegertracing/jaeger/proto-gen/api_v3" dependencyStoreMocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks" "github.com/jaegertracing/jaeger/storage/spanstore" spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks" @@ -106,10 +106,12 @@ func TestGetTrace(t *testing.T) { }, ) require.NoError(t, err) - spansChunk, err := getTraceStream.Recv() + recv, err := getTraceStream.Recv() require.NoError(t, err) - require.Len(t, spansChunk.GetResourceSpans(), 1) - assert.Equal(t, "foobar", spansChunk.GetResourceSpans()[0].GetScopeSpans()[0].GetSpans()[0].GetName()) + td := recv.ToTraces() + require.EqualValues(t, 1, td.SpanCount()) + assert.Equal(t, "foobar", + td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Name()) } func TestGetTraceStorageError(t *testing.T) { @@ -121,10 +123,10 @@ func TestGetTraceStorageError(t *testing.T) { TraceId: "156", }) require.NoError(t, err) - spansChunk, err := getTraceStream.Recv() + recv, err := getTraceStream.Recv() require.Error(t, err) assert.Contains(t, err.Error(), "storage_error") - assert.Nil(t, spansChunk) + assert.Nil(t, recv) } func TestGetTraceTraceIDError(t *testing.T) { @@ -138,10 +140,10 @@ func TestGetTraceTraceIDError(t *testing.T) { TraceId: "Z", }) require.NoError(t, err) - spansChunk, err := getTraceStream.Recv() + recv, err := getTraceStream.Recv() require.Error(t, err) assert.Contains(t, err.Error(), "strconv.ParseUint:") - assert.Nil(t, spansChunk) + assert.Nil(t, recv) } func TestFindTraces(t *testing.T) { @@ -171,7 +173,8 @@ func TestFindTraces(t *testing.T) { require.NoError(t, err) recv, err := responseStream.Recv() require.NoError(t, err) - assert.Len(t, recv.GetResourceSpans(), 1) + td := recv.ToTraces() + require.EqualValues(t, 1, td.SpanCount()) } func TestFindTracesQueryNil(t *testing.T) { diff --git a/cmd/query/app/apiv3/http_gateway.go b/cmd/query/app/apiv3/http_gateway.go index 9aa09a07775..fd98c09e140 100644 --- a/cmd/query/app/apiv3/http_gateway.go +++ b/cmd/query/app/apiv3/http_gateway.go @@ -15,15 +15,15 @@ import ( "github.com/gogo/protobuf/jsonpb" "github.com/gogo/protobuf/proto" "github.com/gorilla/mux" + "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.uber.org/zap" + "github.com/jaegertracing/jaeger/cmd/query/app/internal/api_v3" "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/jtracer" "github.com/jaegertracing/jaeger/pkg/tenancy" - "github.com/jaegertracing/jaeger/proto-gen/api_v3" - tracev1 "github.com/jaegertracing/jaeger/proto-gen/otel/trace/v1" "github.com/jaegertracing/jaeger/storage/spanstore" ) @@ -118,18 +118,16 @@ func (h *HTTPGateway) returnSpans(spans []*model.Span, w http.ResponseWriter) { func (h *HTTPGateway) returnSpansTestable( spans []*model.Span, w http.ResponseWriter, - modelToOTLP func(spans []*model.Span) ([]*tracev1.ResourceSpans, error), + modelToOTLP func(spans []*model.Span) (ptrace.Traces, error), ) { - resourceSpans, err := modelToOTLP(spans) + td, err := modelToOTLP(spans) if h.tryHandleError(w, err, http.StatusInternalServerError) { return } + tracesData := api_v3.TracesData(td) response := &api_v3.GRPCGatewayWrapper{ - Result: &api_v3.SpansResponseChunk{ - ResourceSpans: resourceSpans, - }, + Result: &tracesData, } - h.marshalResponse(response, w) } diff --git a/cmd/query/app/apiv3/http_gateway_test.go b/cmd/query/app/apiv3/http_gateway_test.go index dc0a7f7f35c..edffadb485d 100644 --- a/cmd/query/app/apiv3/http_gateway_test.go +++ b/cmd/query/app/apiv3/http_gateway_test.go @@ -15,6 +15,7 @@ import ( "github.com/gorilla/mux" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/pdata/ptrace" "go.uber.org/zap" "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" @@ -22,7 +23,6 @@ import ( "github.com/jaegertracing/jaeger/pkg/jtracer" "github.com/jaegertracing/jaeger/pkg/tenancy" "github.com/jaegertracing/jaeger/pkg/testutils" - tracev1 "github.com/jaegertracing/jaeger/proto-gen/otel/trace/v1" dependencyStoreMocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks" "github.com/jaegertracing/jaeger/storage/spanstore" spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks" @@ -117,8 +117,8 @@ func TestHTTPGatewayOTLPError(t *testing.T) { } const simErr = "simulated error" gw.returnSpansTestable(nil, w, - func(spans []*model.Span) ([]*tracev1.ResourceSpans, error) { - return nil, fmt.Errorf(simErr) + func(spans []*model.Span) (ptrace.Traces, error) { + return ptrace.Traces{}, fmt.Errorf(simErr) }, ) assert.Contains(t, w.Body.String(), simErr) diff --git a/cmd/query/app/apiv3/otlp_translator.go b/cmd/query/app/apiv3/otlp_translator.go index b7daf1b5567..e88c53643d8 100644 --- a/cmd/query/app/apiv3/otlp_translator.go +++ b/cmd/query/app/apiv3/otlp_translator.go @@ -15,33 +15,13 @@ package apiv3 import ( - "fmt" - - "github.com/gogo/protobuf/proto" model2otel "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger" - "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" + "go.opentelemetry.io/collector/pdata/ptrace" "github.com/jaegertracing/jaeger/model" - "github.com/jaegertracing/jaeger/proto-gen/api_v3" - tracev1 "github.com/jaegertracing/jaeger/proto-gen/otel/trace/v1" ) -func modelToOTLP(spans []*model.Span) ([]*tracev1.ResourceSpans, error) { +func modelToOTLP(spans []*model.Span) (ptrace.Traces, error) { batch := &model.Batch{Spans: spans} - td, err := model2otel.ProtoToTraces([]*model.Batch{batch}) - if err != nil { - return nil, fmt.Errorf("cannot convert trace to OpenTelemetry: %w", err) - } - req := ptraceotlp.NewExportRequestFromTraces(td) - // OTEL Collector hides the internal proto implementation, so do a roundtrip conversion (inefficient) - b, err := req.MarshalProto() - if err != nil { - return nil, fmt.Errorf("cannot marshal OTLP: %w", err) - } - // use api_v3.SpansResponseChunk which has the same shape as otlp.ExportTraceServiceRequest - var chunk api_v3.SpansResponseChunk - if err := proto.Unmarshal(b, &chunk); err != nil { - return nil, fmt.Errorf("cannot marshal OTLP: %w", err) - } - return chunk.ResourceSpans, nil + return model2otel.ProtoToTraces([]*model.Batch{batch}) } diff --git a/cmd/query/app/apiv3/snapshots/FindTraces.json b/cmd/query/app/apiv3/snapshots/FindTraces.json index a1f704a7aef..f9676a145f0 100644 --- a/cmd/query/app/apiv3/snapshots/FindTraces.json +++ b/cmd/query/app/apiv3/snapshots/FindTraces.json @@ -9,15 +9,15 @@ "spans": [ { "endTimeUnixNano": "11651379494838206464", - "kind": "SPAN_KIND_SERVER", + "kind": 2, "name": "foobar", "parentSpanId": "", - "spanId": "AAAAAAAAALQ=", + "spanId": "00000000000000b4", "startTimeUnixNano": "11651379494838206464", "status": { - "code": "STATUS_CODE_ERROR" + "code": 2 }, - "traceId": "AAAAAAAAAJYAAAAAAAAAoA==" + "traceId": "000000000000009600000000000000a0" } ] } diff --git a/cmd/query/app/apiv3/snapshots/GetTrace.json b/cmd/query/app/apiv3/snapshots/GetTrace.json index a1f704a7aef..f9676a145f0 100644 --- a/cmd/query/app/apiv3/snapshots/GetTrace.json +++ b/cmd/query/app/apiv3/snapshots/GetTrace.json @@ -9,15 +9,15 @@ "spans": [ { "endTimeUnixNano": "11651379494838206464", - "kind": "SPAN_KIND_SERVER", + "kind": 2, "name": "foobar", "parentSpanId": "", - "spanId": "AAAAAAAAALQ=", + "spanId": "00000000000000b4", "startTimeUnixNano": "11651379494838206464", "status": { - "code": "STATUS_CODE_ERROR" + "code": 2 }, - "traceId": "AAAAAAAAAJYAAAAAAAAAoA==" + "traceId": "000000000000009600000000000000a0" } ] } diff --git a/proto-gen/api_v3/query_service.pb.go b/cmd/query/app/internal/api_v3/query_service.pb.go similarity index 77% rename from proto-gen/api_v3/query_service.pb.go rename to cmd/query/app/internal/api_v3/query_service.pb.go index 27c35b3148d..2226d7f1b25 100644 --- a/proto-gen/api_v3/query_service.pb.go +++ b/cmd/query/app/internal/api_v3/query_service.pb.go @@ -9,7 +9,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" types "github.com/gogo/protobuf/types" - v1 "github.com/jaegertracing/jaeger/proto-gen/otel/trace/v1" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -87,51 +87,6 @@ func (m *GetTraceRequest) GetEndTime() *time.Time { return nil } -// Response object with spans. -type SpansResponseChunk struct { - // A list of OpenTelemetry ResourceSpans. - // In case of JSON format the ids (trace_id, span_id, parent_id) are encoded in base64 even though OpenTelemetry specification - // mandates to use hex encoding [2]. - // Base64 is chosen to keep compatibility with JSONPb codec. - // [1]: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto - // [2]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlphttp - ResourceSpans []*v1.ResourceSpans `protobuf:"bytes,1,rep,name=resource_spans,json=resourceSpans,proto3" json:"resource_spans,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SpansResponseChunk) Reset() { *m = SpansResponseChunk{} } -func (m *SpansResponseChunk) String() string { return proto.CompactTextString(m) } -func (*SpansResponseChunk) ProtoMessage() {} -func (*SpansResponseChunk) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{1} -} -func (m *SpansResponseChunk) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SpansResponseChunk.Unmarshal(m, b) -} -func (m *SpansResponseChunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SpansResponseChunk.Marshal(b, m, deterministic) -} -func (m *SpansResponseChunk) XXX_Merge(src proto.Message) { - xxx_messageInfo_SpansResponseChunk.Merge(m, src) -} -func (m *SpansResponseChunk) XXX_Size() int { - return xxx_messageInfo_SpansResponseChunk.Size(m) -} -func (m *SpansResponseChunk) XXX_DiscardUnknown() { - xxx_messageInfo_SpansResponseChunk.DiscardUnknown(m) -} - -var xxx_messageInfo_SpansResponseChunk proto.InternalMessageInfo - -func (m *SpansResponseChunk) GetResourceSpans() []*v1.ResourceSpans { - if m != nil { - return m.ResourceSpans - } - return nil -} - // Query parameters to find traces. Except for num_traces, all fields should be treated // as forming a conjunction, e.g., "service_name='X' AND operation_name='Y' AND ...". // All fields are matched against individual spans, not at the trace level. @@ -169,7 +124,7 @@ func (m *TraceQueryParameters) Reset() { *m = TraceQueryParameters{} } func (m *TraceQueryParameters) String() string { return proto.CompactTextString(m) } func (*TraceQueryParameters) ProtoMessage() {} func (*TraceQueryParameters) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{2} + return fileDescriptor_5fcb6756dc1afb8d, []int{1} } func (m *TraceQueryParameters) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_TraceQueryParameters.Unmarshal(m, b) @@ -257,7 +212,7 @@ func (m *FindTracesRequest) Reset() { *m = FindTracesRequest{} } func (m *FindTracesRequest) String() string { return proto.CompactTextString(m) } func (*FindTracesRequest) ProtoMessage() {} func (*FindTracesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{3} + return fileDescriptor_5fcb6756dc1afb8d, []int{2} } func (m *FindTracesRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FindTracesRequest.Unmarshal(m, b) @@ -295,7 +250,7 @@ func (m *GetServicesRequest) Reset() { *m = GetServicesRequest{} } func (m *GetServicesRequest) String() string { return proto.CompactTextString(m) } func (*GetServicesRequest) ProtoMessage() {} func (*GetServicesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{4} + return fileDescriptor_5fcb6756dc1afb8d, []int{3} } func (m *GetServicesRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetServicesRequest.Unmarshal(m, b) @@ -327,7 +282,7 @@ func (m *GetServicesResponse) Reset() { *m = GetServicesResponse{} } func (m *GetServicesResponse) String() string { return proto.CompactTextString(m) } func (*GetServicesResponse) ProtoMessage() {} func (*GetServicesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{5} + return fileDescriptor_5fcb6756dc1afb8d, []int{4} } func (m *GetServicesResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetServicesResponse.Unmarshal(m, b) @@ -369,7 +324,7 @@ func (m *GetOperationsRequest) Reset() { *m = GetOperationsRequest{} } func (m *GetOperationsRequest) String() string { return proto.CompactTextString(m) } func (*GetOperationsRequest) ProtoMessage() {} func (*GetOperationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{6} + return fileDescriptor_5fcb6756dc1afb8d, []int{5} } func (m *GetOperationsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetOperationsRequest.Unmarshal(m, b) @@ -416,7 +371,7 @@ func (m *Operation) Reset() { *m = Operation{} } func (m *Operation) String() string { return proto.CompactTextString(m) } func (*Operation) ProtoMessage() {} func (*Operation) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{7} + return fileDescriptor_5fcb6756dc1afb8d, []int{6} } func (m *Operation) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Operation.Unmarshal(m, b) @@ -462,7 +417,7 @@ func (m *GetOperationsResponse) Reset() { *m = GetOperationsResponse{} } func (m *GetOperationsResponse) String() string { return proto.CompactTextString(m) } func (*GetOperationsResponse) ProtoMessage() {} func (*GetOperationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{8} + return fileDescriptor_5fcb6756dc1afb8d, []int{7} } func (m *GetOperationsResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetOperationsResponse.Unmarshal(m, b) @@ -490,7 +445,6 @@ func (m *GetOperationsResponse) GetOperations() []*Operation { } // GRPCGatewayError is the type returned when GRPC server returns an error. -// Note that for streaming responses it would be wrapped in GRPCGatewayWrapper below. // Example: {"error":{"grpcCode":2,"httpCode":500,"message":"...","httpStatus":"text..."}}. type GRPCGatewayError struct { Error *GRPCGatewayError_GRPCGatewayErrorDetails `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` @@ -503,7 +457,7 @@ func (m *GRPCGatewayError) Reset() { *m = GRPCGatewayError{} } func (m *GRPCGatewayError) String() string { return proto.CompactTextString(m) } func (*GRPCGatewayError) ProtoMessage() {} func (*GRPCGatewayError) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{9} + return fileDescriptor_5fcb6756dc1afb8d, []int{8} } func (m *GRPCGatewayError) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GRPCGatewayError.Unmarshal(m, b) @@ -546,7 +500,7 @@ func (m *GRPCGatewayError_GRPCGatewayErrorDetails) Reset() { func (m *GRPCGatewayError_GRPCGatewayErrorDetails) String() string { return proto.CompactTextString(m) } func (*GRPCGatewayError_GRPCGatewayErrorDetails) ProtoMessage() {} func (*GRPCGatewayError_GRPCGatewayErrorDetails) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{9, 0} + return fileDescriptor_5fcb6756dc1afb8d, []int{8, 0} } func (m *GRPCGatewayError_GRPCGatewayErrorDetails) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GRPCGatewayError_GRPCGatewayErrorDetails.Unmarshal(m, b) @@ -594,25 +548,29 @@ func (m *GRPCGatewayError_GRPCGatewayErrorDetails) GetHttpStatus() string { return "" } -// GRPCGatewayWrapper is a type returned when GRPC service returns a stream. -// For some unknown reason grpc-gateway/v1 wraps chunk responses in {"result": {actual output}}. +// GRPCGatewayWrapper wraps streaming responses from GetTrace/FindTraces for HTTP. +// Today there is always only one response because internally the HTTP server gets +// data from QueryService that does not support multiple responses. But in the +// future the server may return multiple responeses using Transfer-Encoding: chunked. +// In case of errors, GRPCGatewayError above is used. +// +// Example: +// {"result": {"resourceSpans": ...}} +// // See https://github.com/grpc-ecosystem/grpc-gateway/issues/2189 -// TODO: it's not clear what happens when the server returns more than one chunk. -// The gateway will presumably combine then into a single HTTP response. -// Currently this is not possible because even though APIv3 GRPC Service is using output stream, -// its implementation reads all spans from QueryService at once and forms only a single chunk. +// type GRPCGatewayWrapper struct { - Result *SpansResponseChunk `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Result *TracesData `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GRPCGatewayWrapper) Reset() { *m = GRPCGatewayWrapper{} } func (m *GRPCGatewayWrapper) String() string { return proto.CompactTextString(m) } func (*GRPCGatewayWrapper) ProtoMessage() {} func (*GRPCGatewayWrapper) Descriptor() ([]byte, []int) { - return fileDescriptor_5fcb6756dc1afb8d, []int{10} + return fileDescriptor_5fcb6756dc1afb8d, []int{9} } func (m *GRPCGatewayWrapper) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GRPCGatewayWrapper.Unmarshal(m, b) @@ -632,7 +590,7 @@ func (m *GRPCGatewayWrapper) XXX_DiscardUnknown() { var xxx_messageInfo_GRPCGatewayWrapper proto.InternalMessageInfo -func (m *GRPCGatewayWrapper) GetResult() *SpansResponseChunk { +func (m *GRPCGatewayWrapper) GetResult() *TracesData { if m != nil { return m.Result } @@ -641,7 +599,6 @@ func (m *GRPCGatewayWrapper) GetResult() *SpansResponseChunk { func init() { proto.RegisterType((*GetTraceRequest)(nil), "jaeger.api_v3.GetTraceRequest") - proto.RegisterType((*SpansResponseChunk)(nil), "jaeger.api_v3.SpansResponseChunk") proto.RegisterType((*TraceQueryParameters)(nil), "jaeger.api_v3.TraceQueryParameters") proto.RegisterMapType((map[string]string)(nil), "jaeger.api_v3.TraceQueryParameters.AttributesEntry") proto.RegisterType((*FindTracesRequest)(nil), "jaeger.api_v3.FindTracesRequest") @@ -658,61 +615,59 @@ func init() { func init() { proto.RegisterFile("query_service.proto", fileDescriptor_5fcb6756dc1afb8d) } var fileDescriptor_5fcb6756dc1afb8d = []byte{ - // 852 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xef, 0x6e, 0x1b, 0x45, - 0x10, 0xef, 0x39, 0x71, 0x62, 0x8f, 0x93, 0xb4, 0x6c, 0x8d, 0x7a, 0x3d, 0x44, 0xea, 0x5c, 0x41, - 0xb2, 0x84, 0x74, 0x21, 0xc9, 0x07, 0x5a, 0x28, 0x02, 0x9a, 0x16, 0x0b, 0xa1, 0xb4, 0xcd, 0xa6, - 0x80, 0x84, 0x90, 0x4e, 0x9b, 0xdc, 0xe0, 0x1c, 0xf1, 0xed, 0x5d, 0x77, 0xf7, 0x4c, 0xfc, 0x0c, - 0x7c, 0x41, 0xe2, 0x2d, 0x78, 0x29, 0xde, 0x00, 0x5e, 0x01, 0xed, 0x9f, 0xbb, 0xda, 0x67, 0x48, - 0xd3, 0x4f, 0xde, 0x99, 0xfd, 0xfd, 0x66, 0xe6, 0x7e, 0x33, 0xb3, 0x86, 0xdb, 0xaf, 0x4a, 0x14, - 0xb3, 0x58, 0xa2, 0x98, 0xa6, 0x67, 0x18, 0x15, 0x22, 0x57, 0x39, 0xd9, 0xfc, 0x85, 0xe1, 0x18, - 0x45, 0xc4, 0x8a, 0x34, 0x9e, 0x1e, 0x04, 0xc3, 0xbc, 0x40, 0xae, 0x70, 0x82, 0x19, 0x2a, 0x31, - 0xdb, 0x35, 0x98, 0x5d, 0x25, 0xd8, 0x19, 0xee, 0x4e, 0xf7, 0xec, 0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0xcf, 0x50, - 0x4a, 0x36, 0xb6, 0x8f, 0x5d, 0x97, 0x56, 0x26, 0xd9, 0x06, 0xd0, 0xa8, 0x13, 0xc5, 0x54, 0x29, - 0xcd, 0x92, 0x76, 0xe9, 0x9c, 0x27, 0x7c, 0x0e, 0x64, 0xae, 0x98, 0x1f, 0x04, 0x2b, 0x0a, 0x14, - 0xe4, 0x21, 0xac, 0x09, 0x94, 0xe5, 0x44, 0xb9, 0x6f, 0xde, 0x69, 0x7c, 0xf3, 0xf2, 0xeb, 0x48, - 0x1d, 0x61, 0xff, 0xef, 0x16, 0x6c, 0x98, 0x31, 0x74, 0x83, 0x45, 0x8e, 0xa1, 0x53, 0x3d, 0xfc, - 0x64, 0xbb, 0xa9, 0xdd, 0xe2, 0x3f, 0x42, 0xf0, 0xe6, 0x3c, 0xe1, 0x8d, 0x8f, 0x3d, 0xf2, 0x1d, - 0xc0, 0xeb, 0xfd, 0x20, 0x83, 0x06, 0x69, 0x69, 0x75, 0xae, 0x1b, 0xf6, 0x7b, 0xe8, 0xcd, 0x2d, - 0x04, 0xd9, 0x59, 0x2e, 0xb6, 0xb1, 0x42, 0x41, 0x78, 0x15, 0xc4, 0x86, 0x0f, 0x6f, 0x90, 0x9f, - 0x60, 0x73, 0x61, 0x50, 0xc9, 0xfd, 0x65, 0xda, 0xd2, 0x4e, 0x05, 0x1f, 0x5c, 0x0d, 0xaa, 0xa2, - 0x3f, 0xde, 0x81, 0x3b, 0x69, 0xee, 0xb0, 0xfa, 0x3d, 0x4a, 0xf9, 0xd8, 0x51, 0x7e, 0x5c, 0xb3, - 0xbf, 0xa7, 0x6b, 0xe6, 0x35, 0x3b, 0xf8, 0x37, 0x00, 0x00, 0xff, 0xff, 0x01, 0x5e, 0x3d, 0xbf, - 0x2a, 0x08, 0x00, 0x00, + // 819 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd,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, 0x7d, 0x9d, 0x39, 0x4a, 0x63, 0xcf, 0x19, 0x39, 0x63, 0x97, 0x6e, 0x69, 0xfb, + 0xeb, 0x98, 0x7c, 0x01, 0x20, 0x15, 0x13, 0x2a, 0xaa, 0xf2, 0x78, 0x9d, 0x91, 0x33, 0x1e, 0x4c, + 0xfc, 0xd0, 0xe4, 0x08, 0xeb, 0x1c, 0xe1, 0x8b, 0xba, 0x88, 0x47, 0x1b, 0xbf, 0xfd, 0x79, 0xd7, + 0xa1, 0xae, 0xe6, 0x54, 0x5e, 0xf2, 0x19, 0xf4, 0x91, 0xc7, 0x86, 0xde, 0xbd, 0x24, 0x7d, 0x0b, + 0x79, 0x5c, 0xf9, 0x82, 0xdf, 0x37, 0x60, 0xa8, 0x2b, 0x7d, 0x5e, 0x29, 0xfb, 0x8c, 0x09, 0x96, + 0xa1, 0x42, 0x21, 0xc9, 0x1e, 0x6c, 0x5b, 0x99, 0x23, 0xce, 0x32, 0xb4, 0x55, 0x0f, 0xac, 0xef, + 0x29, 0xcb, 0x90, 0x7c, 0x08, 0xd7, 0xf3, 0x02, 0x4d, 0xef, 0x06, 0xd4, 0xd1, 0xa0, 0x9d, 0xc6, + 0xab, 0x61, 0x27, 0x00, 0x4c, 0x29, 0x91, 0x9e, 0x96, 0x0a, 0xa5, 0xd7, 0x1d, 0x75, 0xc7, 0x83, + 0xc9, 0x61, 0xb8, 0x72, 0x69, 0xe1, 0xbf, 0x95, 0x10, 0x7e, 0xd9, 0xb0, 0x9e, 0x70, 0x25, 0x16, + 0x74, 0x29, 0x0c, 0x79, 0x08, 0xd7, 0xdf, 0xaa, 0x16, 0x65, 0x29, 0xf7, 0x36, 0xfe, 0xaf, 0x75, + 0xba, 0xdd, 0x68, 0x76, 0x9c, 0xf2, 0x76, 0x04, 0x76, 0xee, 0xf5, 0xae, 0x12, 0x81, 0x9d, 0x93, + 0x07, 0xb0, 0x5d, 0x5f, 0xbd, 0xae, 0x60, 0x53, 0xf3, 0xef, 0xac,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, 0x91, 0xae, 0x18, 0xfd, 0x25, 0x0c, 0x96, 0xb6, + 0x84, 0xec, 0xad, 0x97, 0xde, 0xda, 0x2b, 0x3f, 0xb8, 0x08, 0x62, 0x46, 0x34, 0xb8, 0x46, 0x5e, + 0xc1, 0xce, 0xca, 0xf4, 0x92, 0x7b, 0xeb, 0xb4, 0xb5, 0x45, 0xf3, 0x3f, 0xb8, 0x18, 0x54, 0x47, + 0x7f, 0xb4, 0x07, 0xb7, 0xd3, 0xdc, 0x62, 0xab, 0xce, 0x52, 0x9e, 0x58, 0xca, 0x0f, 0x9b, 0xe6, + 0x7b, 0xba, 0xa9, 0xfb, 0x3e, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0x04, 0x2f, 0x8b, 0x11, 0xd5, + 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -766,7 +721,7 @@ func (c *queryServiceClient) GetTrace(ctx context.Context, in *GetTraceRequest, } type QueryService_GetTraceClient interface { - Recv() (*SpansResponseChunk, error) + Recv() (*TracesData, error) grpc.ClientStream } @@ -774,8 +729,8 @@ type queryServiceGetTraceClient struct { grpc.ClientStream } -func (x *queryServiceGetTraceClient) Recv() (*SpansResponseChunk, error) { - m := new(SpansResponseChunk) +func (x *queryServiceGetTraceClient) Recv() (*TracesData, error) { + m := new(TracesData) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -798,7 +753,7 @@ func (c *queryServiceClient) FindTraces(ctx context.Context, in *FindTracesReque } type QueryService_FindTracesClient interface { - Recv() (*SpansResponseChunk, error) + Recv() (*TracesData, error) grpc.ClientStream } @@ -806,8 +761,8 @@ type queryServiceFindTracesClient struct { grpc.ClientStream } -func (x *queryServiceFindTracesClient) Recv() (*SpansResponseChunk, error) { - m := new(SpansResponseChunk) +func (x *queryServiceFindTracesClient) Recv() (*TracesData, error) { + m := new(TracesData) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } @@ -879,7 +834,7 @@ func _QueryService_GetTrace_Handler(srv interface{}, stream grpc.ServerStream) e } type QueryService_GetTraceServer interface { - Send(*SpansResponseChunk) error + Send(*TracesData) error grpc.ServerStream } @@ -887,7 +842,7 @@ type queryServiceGetTraceServer struct { grpc.ServerStream } -func (x *queryServiceGetTraceServer) Send(m *SpansResponseChunk) error { +func (x *queryServiceGetTraceServer) Send(m *TracesData) error { return x.ServerStream.SendMsg(m) } @@ -900,7 +855,7 @@ func _QueryService_FindTraces_Handler(srv interface{}, stream grpc.ServerStream) } type QueryService_FindTracesServer interface { - Send(*SpansResponseChunk) error + Send(*TracesData) error grpc.ServerStream } @@ -908,7 +863,7 @@ type queryServiceFindTracesServer struct { grpc.ServerStream } -func (x *queryServiceFindTracesServer) Send(m *SpansResponseChunk) error { +func (x *queryServiceFindTracesServer) Send(m *TracesData) error { return x.ServerStream.SendMsg(m) } diff --git a/cmd/query/app/internal/api_v3/traces.go b/cmd/query/app/internal/api_v3/traces.go new file mode 100644 index 00000000000..c38841c7785 --- /dev/null +++ b/cmd/query/app/internal/api_v3/traces.go @@ -0,0 +1,84 @@ +// Copyright (c) 2024 The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 + +package api_v3 + +import ( + "github.com/gogo/protobuf/jsonpb" + proto "github.com/gogo/protobuf/proto" + "go.opentelemetry.io/collector/pdata/ptrace" + + "github.com/jaegertracing/jaeger/pkg/gogocodec" +) + +// TracesData is an alias to ptrace.Traces that supports Gogo marshaling. +// Our .proto APIs may refer to otlp.TraceData type, but its corresponding +// protoc-generated struct is internal in OTel Collector, so we substitute +// it for this TracesData type that implements marshaling methods by +// delegating to public functions in the OTel Collector's ptrace module. +type TracesData ptrace.Traces + +var ( + _ gogocodec.CustomType = (*TracesData)(nil) + _ proto.Message = (*TracesData)(nil) +) + +func (td TracesData) ToTraces() ptrace.Traces { + return ptrace.Traces(td) +} + +// Marshal implements gogocodec.CustomType. +func (td *TracesData) Marshal() ([]byte, error) { + return new(ptrace.ProtoMarshaler).MarshalTraces(td.ToTraces()) +} + +// MarshalTo implements gogocodec.CustomType. +func (*TracesData) MarshalTo(data []byte) (n int, err error) { + // TODO unclear when this might be called, perhaps when type is embedded inside other structs. + panic("unimplemented") +} + +// MarshalJSONPB implements gogocodec.CustomType. +func (td *TracesData) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) { + return new(ptrace.JSONMarshaler).MarshalTraces(td.ToTraces()) +} + +// UnmarshalJSONPB implements gogocodec.CustomType. +func (td *TracesData) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, data []byte) error { + t, err := new(ptrace.JSONUnmarshaler).UnmarshalTraces(data) + if err != nil { + return err + } + *td = TracesData(t) + return nil +} + +// Size implements gogocodec.CustomType. +func (td *TracesData) Size() int { + return new(ptrace.ProtoMarshaler).TracesSize(td.ToTraces()) +} + +// Unmarshal implements gogocodec.CustomType. +func (td *TracesData) Unmarshal(data []byte) error { + t, err := new(ptrace.ProtoUnmarshaler).UnmarshalTraces(data) + if err != nil { + return err + } + *td = TracesData(t) + return nil +} + +// ProtoMessage implements proto.Message. +func (*TracesData) ProtoMessage() { + // nothing to do here +} + +// Reset implements proto.Message. +func (td *TracesData) Reset() { + *td = TracesData(ptrace.NewTraces()) +} + +// String implements proto.Message. +func (*TracesData) String() string { + return "*TracesData" +} diff --git a/cmd/query/app/internal/api_v3/traces_test.go b/cmd/query/app/internal/api_v3/traces_test.go new file mode 100644 index 00000000000..2ad243b201d --- /dev/null +++ b/cmd/query/app/internal/api_v3/traces_test.go @@ -0,0 +1,62 @@ +// Copyright (c) 2024 The Jaeger Authors. +// SPDX-License-Identifier: Apache-2.0 + +package api_v3 + +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) { + td := TracesData(ptrace.NewTraces()) + + // Test ToTraces + assert.Equal(t, ptrace.Traces(td), td.ToTraces()) + + // Test Marshal + _, err := td.Marshal() + require.NoError(t, err) + + // Test MarshalTo + assert.Panics(t, func() { td.MarshalTo(nil) }) + + // Test MarshalJSONPB + _, err = td.MarshalJSONPB(nil) + require.NoError(t, err) + + // Test UnmarshalJSONPB + err = td.UnmarshalJSONPB(nil, []byte(`{"resourceSpans":[]}`)) + require.NoError(t, err) + + err = td.UnmarshalJSONPB(nil, []byte(`{"resourceSpans":123}`)) + require.Error(t, err) + + // Test Size + assert.Equal(t, 0, td.Size()) + + // Test Unmarshal + err = td.Unmarshal([]byte{}) + require.NoError(t, err) + err = td.Unmarshal([]byte{1}) + require.Error(t, err) + + // Test ProtoMessage + td.ProtoMessage() + + // Test Reset + td.Reset() + assert.Equal(t, TracesData(ptrace.NewTraces()), td) + + // Test String + assert.Equal(t, "*TracesData", td.String()) +} + +func TestMain(m *testing.M) { + testutils.VerifyGoLeaks(m) +} diff --git a/cmd/query/app/server.go b/cmd/query/app/server.go index 27913516fee..1b8e811ebab 100644 --- a/cmd/query/app/server.go +++ b/cmd/query/app/server.go @@ -33,6 +33,7 @@ import ( "google.golang.org/grpc/reflection" "github.com/jaegertracing/jaeger/cmd/query/app/apiv3" + "github.com/jaegertracing/jaeger/cmd/query/app/internal/api_v3" "github.com/jaegertracing/jaeger/cmd/query/app/querysvc" "github.com/jaegertracing/jaeger/pkg/bearertoken" "github.com/jaegertracing/jaeger/pkg/healthcheck" @@ -42,7 +43,6 @@ import ( "github.com/jaegertracing/jaeger/pkg/tenancy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" "github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics" - "github.com/jaegertracing/jaeger/proto-gen/api_v3" ) // Server runs HTTP, Mux and a grpc server diff --git a/idl b/idl index cd5d410a252..a97152c66d8 160000 --- a/idl +++ b/idl @@ -1 +1 @@ -Subproject commit cd5d410a252cc7e4683ad2aa0e7ffe2263539e37 +Subproject commit a97152c66d8f1562fcdcbbb85600d5f12c8aab9e diff --git a/pkg/gogocodec/codec.go b/pkg/gogocodec/codec.go index ac6a59a1f5f..86e94083b4d 100644 --- a/pkg/gogocodec/codec.go +++ b/pkg/gogocodec/codec.go @@ -18,6 +18,7 @@ import ( "reflect" "strings" + "github.com/gogo/protobuf/jsonpb" gogoproto "github.com/gogo/protobuf/proto" "google.golang.org/grpc/encoding" "google.golang.org/grpc/encoding/proto" @@ -31,6 +32,19 @@ const ( var defaultCodec encoding.Codec +// CustomType is an interface that Gogo expects custom types to implement. +// https://github.com/gogo/protobuf/blob/master/custom_types.md +type CustomType interface { + Marshal() ([]byte, error) + MarshalTo(data []byte) (n int, err error) + Unmarshal(data []byte) error + + gogoproto.Sizer + + jsonpb.JSONPBMarshaler + jsonpb.JSONPBUnmarshaler +} + func init() { defaultCodec = encoding.GetCodec(proto.Name) defaultCodec.Name() // ensure it's not nil diff --git a/pkg/testutils/leakcheck.go b/pkg/testutils/leakcheck.go index 188ba75757f..f7e40f00379 100644 --- a/pkg/testutils/leakcheck.go +++ b/pkg/testutils/leakcheck.go @@ -15,6 +15,8 @@ package testutils import ( + "testing" + "go.uber.org/goleak" ) @@ -31,3 +33,8 @@ func IgnoreGlogFlushDaemonLeak() goleak.Option { func IgnoreOpenCensusWorkerLeak() goleak.Option { return goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start") } + +// VerifyGoLeaks verifies that unit tests do not leak any goroutines. +func VerifyGoLeaks(m *testing.M) { + goleak.VerifyTestMain(m, IgnoreGlogFlushDaemonLeak(), IgnoreOpenCensusWorkerLeak()) +} diff --git a/pkg/testutils/leakcheck_test.go b/pkg/testutils/leakcheck_test.go index 6989a58e4a3..f0554f0deab 100644 --- a/pkg/testutils/leakcheck_test.go +++ b/pkg/testutils/leakcheck_test.go @@ -16,14 +16,8 @@ package testutils import ( "testing" - - "github.com/stretchr/testify/require" ) -func TestIgnoreGlogFlushDaemonLeak(t *testing.T) { - require.NotNil(t, IgnoreGlogFlushDaemonLeak()) -} - -func TestIgnoreOpenCensusWorkerLeak(t *testing.T) { - require.NotNil(t, IgnoreOpenCensusWorkerLeak()) +func TestMain(m *testing.M) { + VerifyGoLeaks(m) } diff --git a/pkg/testutils/logger_test.go b/pkg/testutils/logger_test.go index ca659a4034b..d36d96fdcc9 100644 --- a/pkg/testutils/logger_test.go +++ b/pkg/testutils/logger_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "go.uber.org/goleak" "go.uber.org/zap" ) @@ -98,7 +97,3 @@ func TestLogMatcher(t *testing.T) { }) } } - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -}