diff --git a/internal/server/mock/trace/stream_traces.go b/internal/server/mock/trace/stream_traces.go index d48e94b..09da708 100644 --- a/internal/server/mock/trace/stream_traces.go +++ b/internal/server/mock/trace/stream_traces.go @@ -6,6 +6,8 @@ import ( "time" "github.com/brianvoe/gofakeit/v7" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/skpr/api/pb" ) @@ -13,113 +15,62 @@ import ( // 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) + now := time.Now() + + // ~6ms realistic function execution time + latency := 6 * time.Millisecond - for { - resp := &pb.StreamTracesResponse{ - Traces: []*pb.Trace{ - { - 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.TraceFunctionCall{ - { - Name: "PDOStatement::execute", - StartTime: 11479719656578, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\Core\\Database\\StatementPrefetchIterator::execute", - StartTime: 11479719664878, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\sqlite\\Driver\\Database\\sqlite\\Statement::execute", - StartTime: 11479719666498, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\Core\\Database\\Query\\Upsert::execute", - StartTime: 11479719668488, - ElapsedTime: 5999966, - }, - }, - }, - { - 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.TraceFunctionCall{ - { - Name: "PDOStatement::execute", - StartTime: 11479719656578, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\Core\\Database\\StatementPrefetchIterator::execute", - StartTime: 11479719664878, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\sqlite\\Driver\\Database\\sqlite\\Statement::execute", - StartTime: 11479719666498, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\Core\\Database\\Query\\Upsert::execute", - StartTime: 11479719668488, - ElapsedTime: 5999966, - }, - }, - }, - { - Metadata: &pb.TraceMetadata{ - RequestId: gofakeit.UUID(), - 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.TraceFunctionCall{ - { - Name: "PDOStatement::execute", - StartTime: 11479719656578, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\Core\\Database\\StatementPrefetchIterator::execute", - StartTime: 11479719664878, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\sqlite\\Driver\\Database\\sqlite\\Statement::execute", - StartTime: 11479719666498, - ElapsedTime: 5999966, - }, - { - Name: "Drupal\\Core\\Database\\Query\\Upsert::execute", - StartTime: 11479719668488, - ElapsedTime: 5999966, - }, - }, - }, + // Function calls generator with Duration + timestamp + makeFunctionCalls := func(base time.Time) []*pb.TraceFunctionCall { + return []*pb.TraceFunctionCall{ + { + Name: "PDOStatement::execute", + StartTime: timestamppb.New(base), + Elapsed: durationpb.New(latency), + }, + { + Name: "Drupal\\Core\\Database\\StatementPrefetchIterator::execute", + StartTime: timestamppb.New(base.Add(500 * time.Microsecond)), + Elapsed: durationpb.New(latency), + }, + { + Name: "Drupal\\sqlite\\Driver\\Database\\sqlite\\Statement::execute", + StartTime: timestamppb.New(base.Add(1 * time.Millisecond)), + Elapsed: durationpb.New(latency), + }, + { + Name: "Drupal\\Core\\Database\\Query\\Upsert::execute", + StartTime: timestamppb.New(base.Add(1500 * time.Microsecond)), + Elapsed: durationpb.New(latency), }, } + } - err := server.Send(resp) - if err != nil { - return fmt.Errorf("stopping log stream for: %w", err) - } + // Create 3 traces with increasing offsets + traces := make([]*pb.Trace, 0, 3) - time.Sleep(500 * time.Millisecond) + for i := 0; i < 3; i++ { + start := now.Add(time.Duration(i*250) * time.Millisecond) + end := start.Add(50 * time.Millisecond) + + traces = append(traces, &pb.Trace{ + 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: timestamppb.New(start), + EndTime: timestamppb.New(end), + }, + FunctionCalls: makeFunctionCalls(start), + }) } + + resp := &pb.StreamTracesResponse{Traces: traces} + + if err := server.Send(resp); err != nil { + return fmt.Errorf("stopping log stream for: %w", err) + } + + time.Sleep(time.Second) } } diff --git a/pb/trace.pb.go b/pb/trace.pb.go index 07068a0..9ade859 100644 --- a/pb/trace.pb.go +++ b/pb/trace.pb.go @@ -11,6 +11,8 @@ package pb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -184,11 +186,11 @@ type TraceMetadata struct { 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. + 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 *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // Start time of the trace in unix format. + EndTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` // End time of the trace in unix format. } func (x *TraceMetadata) Reset() { @@ -244,18 +246,18 @@ func (x *TraceMetadata) GetMethod() string { return "" } -func (x *TraceMetadata) GetStartTime() int64 { +func (x *TraceMetadata) GetStartTime() *timestamppb.Timestamp { if x != nil { return x.StartTime } - return 0 + return nil } -func (x *TraceMetadata) GetEndTime() int64 { +func (x *TraceMetadata) GetEndTime() *timestamppb.Timestamp { if x != nil { return x.EndTime } - return 0 + return nil } // * @@ -265,9 +267,9 @@ type TraceFunctionCall struct { 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. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Name of the function being traced. + StartTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` // Start time of the function call in unix format. + Elapsed *durationpb.Duration `protobuf:"bytes,3,opt,name=elapsed,proto3" json:"elapsed,omitempty"` // Elapsed time for the function call in milliseconds. } func (x *TraceFunctionCall) Reset() { @@ -309,63 +311,74 @@ func (x *TraceFunctionCall) GetName() string { return "" } -func (x *TraceFunctionCall) GetStartTime() int64 { +func (x *TraceFunctionCall) GetStartTime() *timestamppb.Timestamp { if x != nil { return x.StartTime } - return 0 + return nil } -func (x *TraceFunctionCall) GetElapsedTime() int64 { +func (x *TraceFunctionCall) GetElapsed() *durationpb.Duration { if x != nil { - return x.ElapsedTime + return x.Elapsed } - return 0 + return nil } 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, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0xca, 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, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x65, + 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, + 0x6d, 0x65, 0x22, 0x97, 0x01, 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, 0x39, 0x0a, 0x0a, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x65, 0x6c, 0x61, 0x70, 0x73, + 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 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 ( @@ -382,23 +395,29 @@ func file_trace_proto_rawDescGZIP() []byte { 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 + (*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 + (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp + (*durationpb.Duration)(nil), // 6: google.protobuf.Duration } 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 + 5, // 3: workflow.TraceMetadata.start_time:type_name -> google.protobuf.Timestamp + 5, // 4: workflow.TraceMetadata.end_time:type_name -> google.protobuf.Timestamp + 5, // 5: workflow.TraceFunctionCall.start_time:type_name -> google.protobuf.Timestamp + 6, // 6: workflow.TraceFunctionCall.elapsed:type_name -> google.protobuf.Duration + 0, // 7: workflow.trace.StreamTraces:input_type -> workflow.StreamTracesRequest + 1, // 8: workflow.trace.StreamTraces:output_type -> workflow.StreamTracesResponse + 8, // [8:9] is the sub-list for method output_type + 7, // [7:8] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_trace_proto_init() } diff --git a/trace.proto b/trace.proto index 3936571..fb18057 100644 --- a/trace.proto +++ b/trace.proto @@ -3,6 +3,9 @@ syntax = "proto3"; package workflow; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; + option go_package = "./pb"; service trace { @@ -36,19 +39,19 @@ message Trace { * Metadata which contains information about the trace. */ 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). - int64 start_time = 4; // Start time of the trace in unix format. - int64 end_time = 5; // End time of the trace in unix format. + 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). + google.protobuf.Timestamp start_time = 4; // Start time of the trace in unix format. + google.protobuf.Timestamp end_time = 5; // End time of the trace in unix format. } /** * Function call data within a trace. */ 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. + string name = 1; // Name of the function being traced. + google.protobuf.Timestamp start_time = 2; // Start time of the function call in unix format. + google.protobuf.Duration elapsed = 3; // Elapsed time for the function call in milliseconds. }