diff --git a/internal/storage/v2/grpc/trace_storage.proto b/internal/storage/v2/grpc/trace_storage.proto new file mode 100644 index 00000000000..6a3e3b2b879 --- /dev/null +++ b/internal/storage/v2/grpc/trace_storage.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package jaeger.storage.v2; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "opentelemetry/proto/trace/v1/trace.proto"; + +option go_package = "storage"; + +// GetTraceParams represents the query for a single trace from the storage backend. +message GetTraceParams { + // trace_id is a 16 byte array containing the unique identifier for the trace to query. + bytes trace_id = 1; + + // start_time is the start of the time interval to search for the trace_id. + // + // This field is optional. + google.protobuf.Timestamp start_time = 2 [ + (gogoproto.stdtime) = true + ]; + + // end_time is the end of the time interval to search for the trace_id. + // + // This field is optional. + google.protobuf.Timestamp end_time = 3 [ + (gogoproto.stdtime) = true + ]; +} + +// GetTracesRequest represents a request to retrieve multiple traces. +message GetTracesRequest { + repeated GetTraceParams query = 1; +} + +service TraceReader { + // GetTraces returns a stream that retrieves all traces with given IDs. + // + // Chunking requirements: + // - A single TracesData chunk MUST NOT contain spans from multiple traces. + // - Large traces MAY be split across multiple, *consecutive* TracesData chunks. + // - Each returned TracesData object MUST NOT be empty. + // + // Edge cases: + // - If no spans are found for any given trace ID, the ID is ignored. + // - If none of the trace IDs are found in the storage, an empty response is returned. + // - If an error is encountered, the stream returns the error and stops. + rpc GetTraces(GetTracesRequest) returns (stream opentelemetry.proto.trace.v1.TracesData) {} +} \ No newline at end of file diff --git a/proto-gen/storage/v2/trace_storage.pb.go b/proto-gen/storage/v2/trace_storage.pb.go new file mode 100644 index 00000000000..131947b5638 --- /dev/null +++ b/proto-gen/storage/v2/trace_storage.pb.go @@ -0,0 +1,291 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: trace_storage.proto + +package storage + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + v1 "go.opentelemetry.io/proto/otlp/trace/v1" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GetTraceParams represents the query for a single trace from the storage backend. +type GetTraceParams struct { + // trace_id is a 16 byte array containing the unique identifier for the trace to query. + TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + // start_time is the start of the time interval to search for the trace_id. + // + // This field is optional. + StartTime *time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time,omitempty"` + // end_time is the end of the time interval to search for the trace_id. + // + // This field is optional. + EndTime *time.Time `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTraceParams) Reset() { *m = GetTraceParams{} } +func (m *GetTraceParams) String() string { return proto.CompactTextString(m) } +func (*GetTraceParams) ProtoMessage() {} +func (*GetTraceParams) Descriptor() ([]byte, []int) { + return fileDescriptor_3441c0fd9397413c, []int{0} +} +func (m *GetTraceParams) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTraceParams.Unmarshal(m, b) +} +func (m *GetTraceParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTraceParams.Marshal(b, m, deterministic) +} +func (m *GetTraceParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTraceParams.Merge(m, src) +} +func (m *GetTraceParams) XXX_Size() int { + return xxx_messageInfo_GetTraceParams.Size(m) +} +func (m *GetTraceParams) XXX_DiscardUnknown() { + xxx_messageInfo_GetTraceParams.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTraceParams proto.InternalMessageInfo + +func (m *GetTraceParams) GetTraceId() []byte { + if m != nil { + return m.TraceId + } + return nil +} + +func (m *GetTraceParams) GetStartTime() *time.Time { + if m != nil { + return m.StartTime + } + return nil +} + +func (m *GetTraceParams) GetEndTime() *time.Time { + if m != nil { + return m.EndTime + } + return nil +} + +// GetTracesRequest represents a request to retrieve multiple traces. +type GetTracesRequest struct { + Query []*GetTraceParams `protobuf:"bytes,1,rep,name=query,proto3" json:"query,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetTracesRequest) Reset() { *m = GetTracesRequest{} } +func (m *GetTracesRequest) String() string { return proto.CompactTextString(m) } +func (*GetTracesRequest) ProtoMessage() {} +func (*GetTracesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3441c0fd9397413c, []int{1} +} +func (m *GetTracesRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetTracesRequest.Unmarshal(m, b) +} +func (m *GetTracesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetTracesRequest.Marshal(b, m, deterministic) +} +func (m *GetTracesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTracesRequest.Merge(m, src) +} +func (m *GetTracesRequest) XXX_Size() int { + return xxx_messageInfo_GetTracesRequest.Size(m) +} +func (m *GetTracesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetTracesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTracesRequest proto.InternalMessageInfo + +func (m *GetTracesRequest) GetQuery() []*GetTraceParams { + if m != nil { + return m.Query + } + return nil +} + +func init() { + proto.RegisterType((*GetTraceParams)(nil), "jaeger.storage.v2.GetTraceParams") + proto.RegisterType((*GetTracesRequest)(nil), "jaeger.storage.v2.GetTracesRequest") +} + +func init() { proto.RegisterFile("trace_storage.proto", fileDescriptor_3441c0fd9397413c) } + +var fileDescriptor_3441c0fd9397413c = []byte{ + // 313 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xb1, 0x4e, 0xfb, 0x30, + 0x10, 0xc6, 0xff, 0xfe, 0x17, 0x68, 0xeb, 0x20, 0x04, 0x86, 0x21, 0x64, 0x69, 0x08, 0x4b, 0x26, + 0x87, 0x86, 0x81, 0x81, 0x01, 0xa9, 0x42, 0x42, 0x88, 0x05, 0x45, 0x9d, 0x18, 0xa8, 0x5c, 0x72, + 0x58, 0x45, 0x4d, 0x9c, 0xda, 0x97, 0x48, 0x7d, 0x0b, 0x5e, 0x83, 0xa7, 0xe2, 0x55, 0x50, 0xec, + 0x06, 0xa9, 0x42, 0x42, 0x6c, 0x77, 0x9f, 0x7f, 0x77, 0xf7, 0xf9, 0xa3, 0xc7, 0xa8, 0xc5, 0x0b, + 0xcc, 0x0c, 0x2a, 0x2d, 0x24, 0xf0, 0x4a, 0x2b, 0x54, 0xec, 0xe8, 0x4d, 0x80, 0x04, 0xcd, 0x3b, + 0xb5, 0x49, 0x83, 0x13, 0xa9, 0xa4, 0xb2, 0xaf, 0x49, 0x5b, 0x39, 0x30, 0x18, 0x49, 0xa5, 0xe4, + 0x12, 0x12, 0xdb, 0xcd, 0xeb, 0xd7, 0x04, 0x17, 0x05, 0x18, 0x14, 0x45, 0xb5, 0x01, 0x62, 0x55, + 0x41, 0x89, 0xb0, 0x84, 0x02, 0x50, 0xaf, 0x1d, 0x97, 0xd8, 0x93, 0x49, 0x33, 0x76, 0x85, 0x23, + 0xa3, 0x0f, 0x42, 0x0f, 0xee, 0x00, 0xa7, 0xad, 0xf4, 0x28, 0xb4, 0x28, 0x0c, 0x3b, 0xa5, 0x03, + 0xe7, 0x6e, 0x91, 0xfb, 0x24, 0x24, 0xf1, 0x7e, 0xd6, 0xb7, 0xfd, 0x7d, 0xce, 0x6e, 0x28, 0x35, + 0x28, 0x34, 0xce, 0xda, 0x83, 0xfe, 0xff, 0x90, 0xc4, 0x5e, 0x1a, 0x70, 0xe7, 0x86, 0x77, 0x6e, + 0xf8, 0xb4, 0x73, 0x33, 0xd9, 0x79, 0xff, 0x1c, 0x91, 0x6c, 0x68, 0x67, 0x5a, 0x95, 0x5d, 0xd3, + 0x01, 0x94, 0xb9, 0x1b, 0xef, 0xfd, 0x71, 0xbc, 0x0f, 0x65, 0xde, 0x6a, 0xd1, 0x03, 0x3d, 0xec, + 0xac, 0x9a, 0x0c, 0x56, 0x35, 0x18, 0x64, 0x57, 0x74, 0x77, 0x55, 0x83, 0x5e, 0xfb, 0x24, 0xec, + 0xc5, 0x5e, 0x7a, 0xc6, 0x7f, 0x64, 0xc8, 0xb7, 0xbf, 0x97, 0x39, 0x3e, 0x2d, 0xa8, 0x67, 0xd5, + 0x0c, 0x44, 0x0e, 0x9a, 0x3d, 0xd3, 0xe1, 0xf7, 0x6e, 0x76, 0xfe, 0xcb, 0x96, 0xee, 0x72, 0x10, + 0xf3, 0xad, 0x90, 0x9d, 0x7f, 0xee, 0xb2, 0x6d, 0xc6, 0xdc, 0xc1, 0xb7, 0x02, 0x45, 0xf4, 0xef, + 0x82, 0x4c, 0x86, 0x4f, 0xfd, 0xcd, 0xb2, 0xf9, 0x9e, 0x25, 0x2f, 0xbf, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x73, 0xab, 0xe9, 0x6f, 0x04, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// TraceReaderClient is the client API for TraceReader service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type TraceReaderClient interface { + // GetTraces returns a stream that retrieves all traces with given IDs. + // + // Chunking requirements: + // - A single TracesData chunk MUST NOT contain spans from multiple traces. + // - Large traces MAY be split across multiple, *consecutive* TracesData chunks. + // - Each returned TracesData object MUST NOT be empty. + // + // Edge cases: + // - If no spans are found for any given trace ID, the ID is ignored. + // - If none of the trace IDs are found in the storage, an empty response is returned. + // - If an error is encountered, the stream returns the error and stops. + GetTraces(ctx context.Context, in *GetTracesRequest, opts ...grpc.CallOption) (TraceReader_GetTracesClient, error) +} + +type traceReaderClient struct { + cc *grpc.ClientConn +} + +func NewTraceReaderClient(cc *grpc.ClientConn) TraceReaderClient { + return &traceReaderClient{cc} +} + +func (c *traceReaderClient) GetTraces(ctx context.Context, in *GetTracesRequest, opts ...grpc.CallOption) (TraceReader_GetTracesClient, error) { + stream, err := c.cc.NewStream(ctx, &_TraceReader_serviceDesc.Streams[0], "/jaeger.storage.v2.TraceReader/GetTraces", opts...) + if err != nil { + return nil, err + } + x := &traceReaderGetTracesClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type TraceReader_GetTracesClient interface { + Recv() (*v1.TracesData, error) + grpc.ClientStream +} + +type traceReaderGetTracesClient struct { + grpc.ClientStream +} + +func (x *traceReaderGetTracesClient) Recv() (*v1.TracesData, error) { + m := new(v1.TracesData) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TraceReaderServer is the server API for TraceReader service. +type TraceReaderServer interface { + // GetTraces returns a stream that retrieves all traces with given IDs. + // + // Chunking requirements: + // - A single TracesData chunk MUST NOT contain spans from multiple traces. + // - Large traces MAY be split across multiple, *consecutive* TracesData chunks. + // - Each returned TracesData object MUST NOT be empty. + // + // Edge cases: + // - If no spans are found for any given trace ID, the ID is ignored. + // - If none of the trace IDs are found in the storage, an empty response is returned. + // - If an error is encountered, the stream returns the error and stops. + GetTraces(*GetTracesRequest, TraceReader_GetTracesServer) error +} + +// UnimplementedTraceReaderServer can be embedded to have forward compatible implementations. +type UnimplementedTraceReaderServer struct { +} + +func (*UnimplementedTraceReaderServer) GetTraces(req *GetTracesRequest, srv TraceReader_GetTracesServer) error { + return status.Errorf(codes.Unimplemented, "method GetTraces not implemented") +} + +func RegisterTraceReaderServer(s *grpc.Server, srv TraceReaderServer) { + s.RegisterService(&_TraceReader_serviceDesc, srv) +} + +func _TraceReader_GetTraces_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetTracesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TraceReaderServer).GetTraces(m, &traceReaderGetTracesServer{stream}) +} + +type TraceReader_GetTracesServer interface { + Send(*v1.TracesData) error + grpc.ServerStream +} + +type traceReaderGetTracesServer struct { + grpc.ServerStream +} + +func (x *traceReaderGetTracesServer) Send(m *v1.TracesData) error { + return x.ServerStream.SendMsg(m) +} + +var _TraceReader_serviceDesc = grpc.ServiceDesc{ + ServiceName: "jaeger.storage.v2.TraceReader", + HandlerType: (*TraceReaderServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "GetTraces", + Handler: _TraceReader_GetTraces_Handler, + ServerStreams: true, + }, + }, + Metadata: "trace_storage.proto", +} diff --git a/scripts/makefiles/Protobuf.mk b/scripts/makefiles/Protobuf.mk index 2125e334b22..579e89c02fa 100644 --- a/scripts/makefiles/Protobuf.mk +++ b/scripts/makefiles/Protobuf.mk @@ -24,7 +24,8 @@ PATCHED_OTEL_PROTO_DIR = proto-gen/.patched-otel-proto PROTO_INCLUDES := \ -Iidl/proto/api_v2 \ -Imodel/proto/metrics \ - -I/usr/include/github.com/gogo/protobuf + -I/usr/include/github.com/gogo/protobuf \ + -Iidl/opentelemetry-proto # Remapping of std types to gogo types (must not contain spaces) PROTO_GOGO_MAPPINGS := $(shell echo \ @@ -79,6 +80,7 @@ endef .PHONY: proto proto: proto-storage-v1 \ + proto-storage-v2 \ proto-hotrod \ proto-zipkin \ proto-openmetrics \ @@ -107,6 +109,10 @@ proto-storage-v1: --go_out=$(PWD)/internal/storage/v1/grpc/proto/ \ internal/storage/v1/grpc/proto/storage_test.proto +.PHONY: proto-storage-v2 +proto-storage-v2: + $(call proto_compile, proto-gen/storage/v2, internal/storage/v2/grpc/trace_storage.proto, -Iinternal/storage/v2/grpc/) + .PHONY: proto-hotrod proto-hotrod: $(call proto_compile, , examples/hotrod/services/driver/driver.proto)