Skip to content

Commit e840178

Browse files
committed
Added option to set timestamps to pb response
1 parent 9cf63d4 commit e840178

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

internal/lightstep_pb/grpc/server.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package grpc
33
import (
44
"context"
55
"errors"
6+
"google.golang.org/protobuf/types/known/timestamppb"
67
"net"
78
"sync"
9+
"time"
810

911
"go.opentelemetry.io/collector/component/componentstatus"
1012
"go.opentelemetry.io/collector/config/configgrpc"
@@ -93,15 +95,17 @@ func (s *ServerGRPC) Report(ctx context.Context, rq *pb.ReportRequest) (*pb.Repo
9395
spanCount int
9496
)
9597
ctx = client.NewContext(ctx, client.Info{})
96-
98+
receivedAt := time.Now()
9799
ctx = s.obsreport.StartTracesOp(ctx)
98100
spanCount = len(rq.Spans)
99101
s.logger.Debug("report", zap.Any("incoming", rq))
100102
lr := lightstep_pb.NewLightstepRequest(rq, s.telemetry, transport)
101103
if projectTraces, err = lr.ToOtel(ctx); err != nil {
102104
s.telemetry.IncrementFailed(transport, 1)
103105
return &pb.ReportResponse{
104-
Errors: []string{err.Error()},
106+
Errors: []string{err.Error()},
107+
ReceiveTimestamp: timestamppb.New(receivedAt),
108+
TransmitTimestamp: timestamppb.Now(),
105109
}, err
106110
}
107111
s.telemetry.IncrementProcessed(transport, 1)
@@ -118,11 +122,15 @@ func (s *ServerGRPC) Report(ctx context.Context, rq *pb.ReportRequest) (*pb.Repo
118122

119123
if err != nil {
120124
return &pb.ReportResponse{
121-
Errors: []string{err.Error()},
125+
Errors: []string{err.Error()},
126+
ReceiveTimestamp: timestamppb.New(receivedAt),
127+
TransmitTimestamp: timestamppb.Now(),
122128
}, err
123129
}
124130

125131
return &pb.ReportResponse{
126-
Errors: nil,
132+
Errors: nil,
133+
ReceiveTimestamp: timestamppb.New(receivedAt),
134+
TransmitTimestamp: timestamppb.Now(),
127135
}, nil
128136
}

0 commit comments

Comments
 (0)