diff --git a/cmd/apiserver-mock/main.go b/cmd/apiserver-mock/main.go index 6bd409c..d64f66b 100644 --- a/cmd/apiserver-mock/main.go +++ b/cmd/apiserver-mock/main.go @@ -16,7 +16,6 @@ import ( "github.com/skpr/api/internal/model" "github.com/skpr/api/internal/server/mock/backup" - "github.com/skpr/api/internal/server/mock/compass" "github.com/skpr/api/internal/server/mock/config" "github.com/skpr/api/internal/server/mock/cron" "github.com/skpr/api/internal/server/mock/environment" @@ -27,6 +26,7 @@ import ( "github.com/skpr/api/internal/server/mock/project" "github.com/skpr/api/internal/server/mock/purge" "github.com/skpr/api/internal/server/mock/restore" + "github.com/skpr/api/internal/server/mock/trace" "github.com/skpr/api/internal/server/mock/version" "github.com/skpr/api/pb" ) @@ -78,8 +78,8 @@ func main() { Model: globalModel, }) - log.Println("Registering service: Compass") - pb.RegisterCompassServer(server, &compass.Server{}) + log.Println("Registering service: Trace") + pb.RegisterTraceServer(server, &trace.Server{}) log.Println("Registering service: Config") pb.RegisterConfigServer(server, &config.Server{ diff --git a/internal/server/mock/compass/server.go b/internal/server/mock/compass/server.go deleted file mode 100644 index 9e6570f..0000000 --- a/internal/server/mock/compass/server.go +++ /dev/null @@ -1,10 +0,0 @@ -package compass - -import ( - "github.com/skpr/api/pb" -) - -// Server implements the GRPC "compass" definition. -type Server struct { - pb.UnimplementedCompassServer -} diff --git a/internal/server/mock/trace/server.go b/internal/server/mock/trace/server.go new file mode 100644 index 0000000..1568a4d --- /dev/null +++ b/internal/server/mock/trace/server.go @@ -0,0 +1,10 @@ +package trace + +import ( + "github.com/skpr/api/pb" +) + +// Server implements the GRPC "trace" definition. +type Server struct { + pb.UnimplementedTraceServer +} diff --git a/internal/server/mock/compass/stream_traces.go b/internal/server/mock/trace/stream_traces.go similarity index 87% rename from internal/server/mock/compass/stream_traces.go rename to internal/server/mock/trace/stream_traces.go index bf91853..d48e94b 100644 --- a/internal/server/mock/compass/stream_traces.go +++ b/internal/server/mock/trace/stream_traces.go @@ -1,4 +1,4 @@ -package compass +package trace import ( "fmt" @@ -10,24 +10,24 @@ import ( "github.com/skpr/api/pb" ) -// StreamTraces streams Compass traces from a specific environment. -func (s *Server) StreamTraces(_ *pb.StreamTracesRequest, server pb.Compass_StreamTracesServer) error { +// StreamTraces streams traces from a specific environment. +func (s *Server) StreamTraces(_ *pb.StreamTracesRequest, server pb.Trace_StreamTracesServer) error { for { // Simulate some processing delay. time.Sleep(time.Second) for { resp := &pb.StreamTracesResponse{ - Traces: []*pb.CompassTrace{ + Traces: []*pb.Trace{ { - Metadata: &pb.CompassTraceMetadata{ + Metadata: &pb.TraceMetadata{ RequestId: gofakeit.UUID(), Method: http.MethodGet, Uri: "/sites/default/files/styles/scale_crop_7_3_wide/public/veggie-pasta-bake-hero-umami.jpg.webp?itok=CYsHBUlX", StartTime: 11479712402527, EndTime: 11480550685871, }, - FunctionCalls: []*pb.CompassTraceFunctionCall{ + FunctionCalls: []*pb.TraceFunctionCall{ { Name: "PDOStatement::execute", StartTime: 11479719656578, @@ -51,14 +51,14 @@ func (s *Server) StreamTraces(_ *pb.StreamTracesRequest, server pb.Compass_Strea }, }, { - Metadata: &pb.CompassTraceMetadata{ + Metadata: &pb.TraceMetadata{ RequestId: gofakeit.UUID(), Method: http.MethodGet, Uri: "/sites/default/files/styles/scale_crop_7_3_wide/public/veggie-pasta-bake-hero-umami.jpg.webp?itok=CYsHBUlX", StartTime: 11479712402527, EndTime: 11480550685871, }, - FunctionCalls: []*pb.CompassTraceFunctionCall{ + FunctionCalls: []*pb.TraceFunctionCall{ { Name: "PDOStatement::execute", StartTime: 11479719656578, @@ -82,14 +82,13 @@ func (s *Server) StreamTraces(_ *pb.StreamTracesRequest, server pb.Compass_Strea }, }, { - Metadata: &pb.CompassTraceMetadata{ + Metadata: &pb.TraceMetadata{ RequestId: gofakeit.UUID(), - Method: http.MethodGet, Uri: "/sites/default/files/styles/scale_crop_7_3_wide/public/veggie-pasta-bake-hero-umami.jpg.webp?itok=CYsHBUlX", StartTime: 11479712402527, EndTime: 11480550685871, }, - FunctionCalls: []*pb.CompassTraceFunctionCall{ + FunctionCalls: []*pb.TraceFunctionCall{ { Name: "PDOStatement::execute", StartTime: 11479719656578, diff --git a/pb/compass.pb.go b/pb/compass.pb.go deleted file mode 100644 index e76d2b7..0000000 --- a/pb/compass.pb.go +++ /dev/null @@ -1,492 +0,0 @@ -//* Service responsible for collecting metrics from Compass - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: compass.proto - -package pb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// * -// Input for StreamTraces. -type StreamTracesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Environment string `protobuf:"bytes,1,opt,name=environment,proto3" json:"environment,omitempty"` // The environment to stream traces from. -} - -func (x *StreamTracesRequest) Reset() { - *x = StreamTracesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_compass_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StreamTracesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamTracesRequest) ProtoMessage() {} - -func (x *StreamTracesRequest) ProtoReflect() protoreflect.Message { - mi := &file_compass_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamTracesRequest.ProtoReflect.Descriptor instead. -func (*StreamTracesRequest) Descriptor() ([]byte, []int) { - return file_compass_proto_rawDescGZIP(), []int{0} -} - -func (x *StreamTracesRequest) GetEnvironment() string { - if x != nil { - return x.Environment - } - return "" -} - -// * -// Output for StreamTraces. -type StreamTracesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Traces []*CompassTrace `protobuf:"bytes,1,rep,name=Traces,proto3" json:"Traces,omitempty"` // List of traces. -} - -func (x *StreamTracesResponse) Reset() { - *x = StreamTracesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_compass_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StreamTracesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamTracesResponse) ProtoMessage() {} - -func (x *StreamTracesResponse) ProtoReflect() protoreflect.Message { - mi := &file_compass_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamTracesResponse.ProtoReflect.Descriptor instead. -func (*StreamTracesResponse) Descriptor() ([]byte, []int) { - return file_compass_proto_rawDescGZIP(), []int{1} -} - -func (x *StreamTracesResponse) GetTraces() []*CompassTrace { - if x != nil { - return x.Traces - } - return nil -} - -// * -// Trace data provided by Compass. -type CompassTrace struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Metadata *CompassTraceMetadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // Metadata about the trace. - FunctionCalls []*CompassTraceFunctionCall `protobuf:"bytes,2,rep,name=function_calls,json=functionCalls,proto3" json:"function_calls,omitempty"` // List of function calls in the trace. -} - -func (x *CompassTrace) Reset() { - *x = CompassTrace{} - if protoimpl.UnsafeEnabled { - mi := &file_compass_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CompassTrace) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CompassTrace) ProtoMessage() {} - -func (x *CompassTrace) ProtoReflect() protoreflect.Message { - mi := &file_compass_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CompassTrace.ProtoReflect.Descriptor instead. -func (*CompassTrace) Descriptor() ([]byte, []int) { - return file_compass_proto_rawDescGZIP(), []int{2} -} - -func (x *CompassTrace) GetMetadata() *CompassTraceMetadata { - if x != nil { - return x.Metadata - } - return nil -} - -func (x *CompassTrace) GetFunctionCalls() []*CompassTraceFunctionCall { - if x != nil { - return x.FunctionCalls - } - return nil -} - -// * -// Metadata which contains information about the Compass trace. -type CompassTraceMetadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // Request identifier for tracking. - Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"` // URI of the request being traced. - Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` // HTTP method of the request (e.g., GET, POST). - StartTime int64 `protobuf:"varint,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // Start time of the trace in unix format. - EndTime int64 `protobuf:"varint,5,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` // End time of the trace in unix format. -} - -func (x *CompassTraceMetadata) Reset() { - *x = CompassTraceMetadata{} - if protoimpl.UnsafeEnabled { - mi := &file_compass_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CompassTraceMetadata) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CompassTraceMetadata) ProtoMessage() {} - -func (x *CompassTraceMetadata) ProtoReflect() protoreflect.Message { - mi := &file_compass_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CompassTraceMetadata.ProtoReflect.Descriptor instead. -func (*CompassTraceMetadata) Descriptor() ([]byte, []int) { - return file_compass_proto_rawDescGZIP(), []int{3} -} - -func (x *CompassTraceMetadata) GetRequestId() string { - if x != nil { - return x.RequestId - } - return "" -} - -func (x *CompassTraceMetadata) GetUri() string { - if x != nil { - return x.Uri - } - return "" -} - -func (x *CompassTraceMetadata) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *CompassTraceMetadata) GetStartTime() int64 { - if x != nil { - return x.StartTime - } - return 0 -} - -func (x *CompassTraceMetadata) GetEndTime() int64 { - if x != nil { - return x.EndTime - } - return 0 -} - -// * -// Function call data within a Compass trace. -type CompassTraceFunctionCall struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Name of the function being traced. - StartTime int64 `protobuf:"varint,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // Start time of the function call in unix format. - ElapsedTime int64 `protobuf:"varint,3,opt,name=elapsed_time,json=elapsedTime,proto3" json:"elapsed_time,omitempty"` // Elapsed time for the function call in milliseconds. -} - -func (x *CompassTraceFunctionCall) Reset() { - *x = CompassTraceFunctionCall{} - if protoimpl.UnsafeEnabled { - mi := &file_compass_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CompassTraceFunctionCall) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CompassTraceFunctionCall) ProtoMessage() {} - -func (x *CompassTraceFunctionCall) ProtoReflect() protoreflect.Message { - mi := &file_compass_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CompassTraceFunctionCall.ProtoReflect.Descriptor instead. -func (*CompassTraceFunctionCall) Descriptor() ([]byte, []int) { - return file_compass_proto_rawDescGZIP(), []int{4} -} - -func (x *CompassTraceFunctionCall) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CompassTraceFunctionCall) GetStartTime() int64 { - if x != nil { - return x.StartTime - } - return 0 -} - -func (x *CompassTraceFunctionCall) GetElapsedTime() int64 { - if x != nil { - return x.ElapsedTime - } - return 0 -} - -var File_compass_proto protoreflect.FileDescriptor - -var file_compass_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x22, 0x37, 0x0a, 0x13, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, - 0x6e, 0x74, 0x22, 0x46, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x54, 0x72, - 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x77, 0x6f, 0x72, - 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, 0x54, 0x72, 0x61, - 0x63, 0x65, 0x52, 0x06, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x22, 0x95, 0x01, 0x0a, 0x0c, 0x43, - 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, - 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, - 0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x49, 0x0a, 0x0e, 0x66, 0x75, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, - 0x73, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, - 0x61, 0x6c, 0x6c, 0x52, 0x0d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, - 0x6c, 0x73, 0x22, 0x99, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, 0x54, 0x72, - 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, - 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x16, 0x0a, 0x06, - 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, - 0x69, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x70, - 0x0a, 0x18, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x46, 0x75, - 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, - 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x21, 0x0a, - 0x0c, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0b, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, - 0x32, 0x5c, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x73, 0x73, 0x12, 0x51, 0x0a, 0x0c, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x77, 0x6f, - 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x77, 0x6f, 0x72, - 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_compass_proto_rawDescOnce sync.Once - file_compass_proto_rawDescData = file_compass_proto_rawDesc -) - -func file_compass_proto_rawDescGZIP() []byte { - file_compass_proto_rawDescOnce.Do(func() { - file_compass_proto_rawDescData = protoimpl.X.CompressGZIP(file_compass_proto_rawDescData) - }) - return file_compass_proto_rawDescData -} - -var file_compass_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_compass_proto_goTypes = []interface{}{ - (*StreamTracesRequest)(nil), // 0: workflow.StreamTracesRequest - (*StreamTracesResponse)(nil), // 1: workflow.StreamTracesResponse - (*CompassTrace)(nil), // 2: workflow.CompassTrace - (*CompassTraceMetadata)(nil), // 3: workflow.CompassTraceMetadata - (*CompassTraceFunctionCall)(nil), // 4: workflow.CompassTraceFunctionCall -} -var file_compass_proto_depIdxs = []int32{ - 2, // 0: workflow.StreamTracesResponse.Traces:type_name -> workflow.CompassTrace - 3, // 1: workflow.CompassTrace.metadata:type_name -> workflow.CompassTraceMetadata - 4, // 2: workflow.CompassTrace.function_calls:type_name -> workflow.CompassTraceFunctionCall - 0, // 3: workflow.compass.StreamTraces:input_type -> workflow.StreamTracesRequest - 1, // 4: workflow.compass.StreamTraces:output_type -> workflow.StreamTracesResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_compass_proto_init() } -func file_compass_proto_init() { - if File_compass_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_compass_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamTracesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_compass_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamTracesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_compass_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompassTrace); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_compass_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompassTraceMetadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_compass_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CompassTraceFunctionCall); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_compass_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_compass_proto_goTypes, - DependencyIndexes: file_compass_proto_depIdxs, - MessageInfos: file_compass_proto_msgTypes, - }.Build() - File_compass_proto = out.File - file_compass_proto_rawDesc = nil - file_compass_proto_goTypes = nil - file_compass_proto_depIdxs = nil -} diff --git a/pb/compass_grpc.pb.go b/pb/compass_grpc.pb.go deleted file mode 100644 index 64ba18c..0000000 --- a/pb/compass_grpc.pb.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: compass.proto - -package pb - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// CompassClient is the client API for Compass service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type CompassClient interface { - // Stream Compass traces from a specific environment. - StreamTraces(ctx context.Context, in *StreamTracesRequest, opts ...grpc.CallOption) (Compass_StreamTracesClient, error) -} - -type compassClient struct { - cc grpc.ClientConnInterface -} - -func NewCompassClient(cc grpc.ClientConnInterface) CompassClient { - return &compassClient{cc} -} - -func (c *compassClient) StreamTraces(ctx context.Context, in *StreamTracesRequest, opts ...grpc.CallOption) (Compass_StreamTracesClient, error) { - stream, err := c.cc.NewStream(ctx, &Compass_ServiceDesc.Streams[0], "/workflow.compass/StreamTraces", opts...) - if err != nil { - return nil, err - } - x := &compassStreamTracesClient{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 Compass_StreamTracesClient interface { - Recv() (*StreamTracesResponse, error) - grpc.ClientStream -} - -type compassStreamTracesClient struct { - grpc.ClientStream -} - -func (x *compassStreamTracesClient) Recv() (*StreamTracesResponse, error) { - m := new(StreamTracesResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// CompassServer is the server API for Compass service. -// All implementations must embed UnimplementedCompassServer -// for forward compatibility -type CompassServer interface { - // Stream Compass traces from a specific environment. - StreamTraces(*StreamTracesRequest, Compass_StreamTracesServer) error - mustEmbedUnimplementedCompassServer() -} - -// UnimplementedCompassServer must be embedded to have forward compatible implementations. -type UnimplementedCompassServer struct { -} - -func (UnimplementedCompassServer) StreamTraces(*StreamTracesRequest, Compass_StreamTracesServer) error { - return status.Errorf(codes.Unimplemented, "method StreamTraces not implemented") -} -func (UnimplementedCompassServer) mustEmbedUnimplementedCompassServer() {} - -// UnsafeCompassServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CompassServer will -// result in compilation errors. -type UnsafeCompassServer interface { - mustEmbedUnimplementedCompassServer() -} - -func RegisterCompassServer(s grpc.ServiceRegistrar, srv CompassServer) { - s.RegisterService(&Compass_ServiceDesc, srv) -} - -func _Compass_StreamTraces_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(StreamTracesRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(CompassServer).StreamTraces(m, &compassStreamTracesServer{stream}) -} - -type Compass_StreamTracesServer interface { - Send(*StreamTracesResponse) error - grpc.ServerStream -} - -type compassStreamTracesServer struct { - grpc.ServerStream -} - -func (x *compassStreamTracesServer) Send(m *StreamTracesResponse) error { - return x.ServerStream.SendMsg(m) -} - -// Compass_ServiceDesc is the grpc.ServiceDesc for Compass service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Compass_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "workflow.compass", - HandlerType: (*CompassServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "StreamTraces", - Handler: _Compass_StreamTraces_Handler, - ServerStreams: true, - }, - }, - Metadata: "compass.proto", -} diff --git a/pb/trace.pb.go b/pb/trace.pb.go new file mode 100644 index 0000000..07068a0 --- /dev/null +++ b/pb/trace.pb.go @@ -0,0 +1,489 @@ +//* Service responsible for collecting metrics from Compass + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: trace.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// * +// Input for StreamTraces. +type StreamTracesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Environment string `protobuf:"bytes,1,opt,name=environment,proto3" json:"environment,omitempty"` // The environment to stream traces from. +} + +func (x *StreamTracesRequest) Reset() { + *x = StreamTracesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StreamTracesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StreamTracesRequest) ProtoMessage() {} + +func (x *StreamTracesRequest) ProtoReflect() protoreflect.Message { + mi := &file_trace_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StreamTracesRequest.ProtoReflect.Descriptor instead. +func (*StreamTracesRequest) Descriptor() ([]byte, []int) { + return file_trace_proto_rawDescGZIP(), []int{0} +} + +func (x *StreamTracesRequest) GetEnvironment() string { + if x != nil { + return x.Environment + } + return "" +} + +// * +// Output for StreamTraces. +type StreamTracesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Traces []*Trace `protobuf:"bytes,1,rep,name=Traces,proto3" json:"Traces,omitempty"` // List of traces. +} + +func (x *StreamTracesResponse) Reset() { + *x = StreamTracesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StreamTracesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StreamTracesResponse) ProtoMessage() {} + +func (x *StreamTracesResponse) ProtoReflect() protoreflect.Message { + mi := &file_trace_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StreamTracesResponse.ProtoReflect.Descriptor instead. +func (*StreamTracesResponse) Descriptor() ([]byte, []int) { + return file_trace_proto_rawDescGZIP(), []int{1} +} + +func (x *StreamTracesResponse) GetTraces() []*Trace { + if x != nil { + return x.Traces + } + return nil +} + +// * +// Trace data provided by Compass. +type Trace struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *TraceMetadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // Metadata about the trace. + FunctionCalls []*TraceFunctionCall `protobuf:"bytes,2,rep,name=function_calls,json=functionCalls,proto3" json:"function_calls,omitempty"` // List of function calls in the trace. +} + +func (x *Trace) Reset() { + *x = Trace{} + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Trace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trace) ProtoMessage() {} + +func (x *Trace) ProtoReflect() protoreflect.Message { + mi := &file_trace_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trace.ProtoReflect.Descriptor instead. +func (*Trace) Descriptor() ([]byte, []int) { + return file_trace_proto_rawDescGZIP(), []int{2} +} + +func (x *Trace) GetMetadata() *TraceMetadata { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *Trace) GetFunctionCalls() []*TraceFunctionCall { + if x != nil { + return x.FunctionCalls + } + return nil +} + +// * +// Metadata which contains information about the trace. +type TraceMetadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // Request identifier for tracking. + Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"` // URI of the request being traced. + Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` // HTTP method of the request (e.g., GET, POST). + StartTime int64 `protobuf:"varint,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // Start time of the trace in unix format. + EndTime int64 `protobuf:"varint,5,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` // End time of the trace in unix format. +} + +func (x *TraceMetadata) Reset() { + *x = TraceMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TraceMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TraceMetadata) ProtoMessage() {} + +func (x *TraceMetadata) ProtoReflect() protoreflect.Message { + mi := &file_trace_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TraceMetadata.ProtoReflect.Descriptor instead. +func (*TraceMetadata) Descriptor() ([]byte, []int) { + return file_trace_proto_rawDescGZIP(), []int{3} +} + +func (x *TraceMetadata) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *TraceMetadata) GetUri() string { + if x != nil { + return x.Uri + } + return "" +} + +func (x *TraceMetadata) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *TraceMetadata) GetStartTime() int64 { + if x != nil { + return x.StartTime + } + return 0 +} + +func (x *TraceMetadata) GetEndTime() int64 { + if x != nil { + return x.EndTime + } + return 0 +} + +// * +// Function call data within a trace. +type TraceFunctionCall struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Name of the function being traced. + StartTime int64 `protobuf:"varint,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // Start time of the function call in unix format. + ElapsedTime int64 `protobuf:"varint,3,opt,name=elapsed_time,json=elapsedTime,proto3" json:"elapsed_time,omitempty"` // Elapsed time for the function call in milliseconds. +} + +func (x *TraceFunctionCall) Reset() { + *x = TraceFunctionCall{} + if protoimpl.UnsafeEnabled { + mi := &file_trace_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TraceFunctionCall) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TraceFunctionCall) ProtoMessage() {} + +func (x *TraceFunctionCall) ProtoReflect() protoreflect.Message { + mi := &file_trace_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TraceFunctionCall.ProtoReflect.Descriptor instead. +func (*TraceFunctionCall) Descriptor() ([]byte, []int) { + return file_trace_proto_rawDescGZIP(), []int{4} +} + +func (x *TraceFunctionCall) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *TraceFunctionCall) GetStartTime() int64 { + if x != nil { + return x.StartTime + } + return 0 +} + +func (x *TraceFunctionCall) GetElapsedTime() int64 { + if x != nil { + return x.ElapsedTime + } + return 0 +} + +var File_trace_proto protoreflect.FileDescriptor + +var file_trace_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x77, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x22, 0x37, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, + 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, + 0x22, 0x3f, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x06, 0x54, 0x72, 0x61, 0x63, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x06, 0x54, 0x72, 0x61, 0x63, 0x65, + 0x73, 0x22, 0x80, 0x01, 0x0a, 0x05, 0x54, 0x72, 0x61, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x42, 0x0a, 0x0e, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x61, 0x6c, + 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x77, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x0d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, + 0x61, 0x6c, 0x6c, 0x73, 0x22, 0x92, 0x01, 0x0a, 0x0d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, + 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x69, 0x0a, 0x11, 0x54, 0x72, 0x61, + 0x63, 0x65, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, + 0x54, 0x69, 0x6d, 0x65, 0x32, 0x5a, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x63, 0x65, 0x12, 0x51, 0x0a, + 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x12, 0x1d, 0x2e, + 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, + 0x72, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x77, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x54, 0x72, + 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, + 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_trace_proto_rawDescOnce sync.Once + file_trace_proto_rawDescData = file_trace_proto_rawDesc +) + +func file_trace_proto_rawDescGZIP() []byte { + file_trace_proto_rawDescOnce.Do(func() { + file_trace_proto_rawDescData = protoimpl.X.CompressGZIP(file_trace_proto_rawDescData) + }) + return file_trace_proto_rawDescData +} + +var file_trace_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_trace_proto_goTypes = []interface{}{ + (*StreamTracesRequest)(nil), // 0: workflow.StreamTracesRequest + (*StreamTracesResponse)(nil), // 1: workflow.StreamTracesResponse + (*Trace)(nil), // 2: workflow.Trace + (*TraceMetadata)(nil), // 3: workflow.TraceMetadata + (*TraceFunctionCall)(nil), // 4: workflow.TraceFunctionCall +} +var file_trace_proto_depIdxs = []int32{ + 2, // 0: workflow.StreamTracesResponse.Traces:type_name -> workflow.Trace + 3, // 1: workflow.Trace.metadata:type_name -> workflow.TraceMetadata + 4, // 2: workflow.Trace.function_calls:type_name -> workflow.TraceFunctionCall + 0, // 3: workflow.trace.StreamTraces:input_type -> workflow.StreamTracesRequest + 1, // 4: workflow.trace.StreamTraces:output_type -> workflow.StreamTracesResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_trace_proto_init() } +func file_trace_proto_init() { + if File_trace_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_trace_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StreamTracesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_trace_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StreamTracesResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_trace_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Trace); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_trace_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TraceMetadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_trace_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TraceFunctionCall); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_trace_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_trace_proto_goTypes, + DependencyIndexes: file_trace_proto_depIdxs, + MessageInfos: file_trace_proto_msgTypes, + }.Build() + File_trace_proto = out.File + file_trace_proto_rawDesc = nil + file_trace_proto_goTypes = nil + file_trace_proto_depIdxs = nil +} diff --git a/pb/trace_grpc.pb.go b/pb/trace_grpc.pb.go new file mode 100644 index 0000000..682f333 --- /dev/null +++ b/pb/trace_grpc.pb.go @@ -0,0 +1,134 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.12 +// source: trace.proto + +package pb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// TraceClient is the client API for Trace service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type TraceClient interface { + // Stream Compass traces from a specific environment. + StreamTraces(ctx context.Context, in *StreamTracesRequest, opts ...grpc.CallOption) (Trace_StreamTracesClient, error) +} + +type traceClient struct { + cc grpc.ClientConnInterface +} + +func NewTraceClient(cc grpc.ClientConnInterface) TraceClient { + return &traceClient{cc} +} + +func (c *traceClient) StreamTraces(ctx context.Context, in *StreamTracesRequest, opts ...grpc.CallOption) (Trace_StreamTracesClient, error) { + stream, err := c.cc.NewStream(ctx, &Trace_ServiceDesc.Streams[0], "/workflow.trace/StreamTraces", opts...) + if err != nil { + return nil, err + } + x := &traceStreamTracesClient{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 Trace_StreamTracesClient interface { + Recv() (*StreamTracesResponse, error) + grpc.ClientStream +} + +type traceStreamTracesClient struct { + grpc.ClientStream +} + +func (x *traceStreamTracesClient) Recv() (*StreamTracesResponse, error) { + m := new(StreamTracesResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TraceServer is the server API for Trace service. +// All implementations must embed UnimplementedTraceServer +// for forward compatibility +type TraceServer interface { + // Stream Compass traces from a specific environment. + StreamTraces(*StreamTracesRequest, Trace_StreamTracesServer) error + mustEmbedUnimplementedTraceServer() +} + +// UnimplementedTraceServer must be embedded to have forward compatible implementations. +type UnimplementedTraceServer struct { +} + +func (UnimplementedTraceServer) StreamTraces(*StreamTracesRequest, Trace_StreamTracesServer) error { + return status.Errorf(codes.Unimplemented, "method StreamTraces not implemented") +} +func (UnimplementedTraceServer) mustEmbedUnimplementedTraceServer() {} + +// UnsafeTraceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TraceServer will +// result in compilation errors. +type UnsafeTraceServer interface { + mustEmbedUnimplementedTraceServer() +} + +func RegisterTraceServer(s grpc.ServiceRegistrar, srv TraceServer) { + s.RegisterService(&Trace_ServiceDesc, srv) +} + +func _Trace_StreamTraces_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(StreamTracesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TraceServer).StreamTraces(m, &traceStreamTracesServer{stream}) +} + +type Trace_StreamTracesServer interface { + Send(*StreamTracesResponse) error + grpc.ServerStream +} + +type traceStreamTracesServer struct { + grpc.ServerStream +} + +func (x *traceStreamTracesServer) Send(m *StreamTracesResponse) error { + return x.ServerStream.SendMsg(m) +} + +// Trace_ServiceDesc is the grpc.ServiceDesc for Trace service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Trace_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "workflow.trace", + HandlerType: (*TraceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamTraces", + Handler: _Trace_StreamTraces_Handler, + ServerStreams: true, + }, + }, + Metadata: "trace.proto", +} diff --git a/compass.proto b/trace.proto similarity index 70% rename from compass.proto rename to trace.proto index 6019c42..3936571 100644 --- a/compass.proto +++ b/trace.proto @@ -5,7 +5,7 @@ package workflow; option go_package = "./pb"; -service compass { +service trace { // Stream Compass traces from a specific environment. rpc StreamTraces (StreamTracesRequest) returns (stream StreamTracesResponse) {} } @@ -21,21 +21,21 @@ message StreamTracesRequest { * Output for StreamTraces. */ message StreamTracesResponse { - repeated CompassTrace Traces = 1; // List of traces. + repeated Trace Traces = 1; // List of traces. } /** * Trace data provided by Compass. */ -message CompassTrace { - CompassTraceMetadata metadata = 1; // Metadata about the trace. - repeated CompassTraceFunctionCall function_calls = 2; // List of function calls in the trace. +message Trace { + TraceMetadata metadata = 1; // Metadata about the trace. + repeated TraceFunctionCall function_calls = 2; // List of function calls in the trace. } /** - * Metadata which contains information about the Compass trace. + * Metadata which contains information about the trace. */ -message CompassTraceMetadata { +message TraceMetadata { string request_id = 1; // Request identifier for tracking. string uri = 2; // URI of the request being traced. string method = 3; // HTTP method of the request (e.g., GET, POST). @@ -44,9 +44,9 @@ message CompassTraceMetadata { } /** - * Function call data within a Compass trace. + * Function call data within a trace. */ -message CompassTraceFunctionCall { +message TraceFunctionCall { string name = 1; // Name of the function being traced. int64 start_time = 2; // Start time of the function call in unix format. int64 elapsed_time = 3; // Elapsed time for the function call in milliseconds.