MCPcopy
hub / github.com/grafana/tempo / sendSegmented

Method sendSegmented

modules/frontend/pipeline/collector_grpc.go:88–112  ·  view source on GitHub ↗
(req *http.Request, resp T, maxSize int)

Source from the content-addressed store, hash-verified

86}
87
88func (c GRPCCollector[T]) sendSegmented(req *http.Request, resp T, maxSize int) error {
89 // If no max, then send as-is.
90 if maxSize <= 0 {
91 return grpcError(c.send(resp))
92 }
93
94 // Split the response into smaller packets and send individually.
95 grpcPackets, err := c.combiner.GRPCSegment(resp, maxSize)
96 if err != nil {
97 return grpcError(err)
98 }
99
100 for _, packet := range grpcPackets {
101 // While sending, check and return the context errors, like ctx cancelled, etc
102 if req.Context().Err() != nil {
103 return grpcError(req.Context().Err())
104 }
105
106 err = c.send(packet)
107 if err != nil {
108 return grpcError(err)
109 }
110 }
111 return nil
112}
113
114func grpcError(err error) error {
115 // if is already a grpc err then just return. something with more context has already created a

Callers 1

RoundTripMethod · 0.95

Calls 3

grpcErrorFunction · 0.85
GRPCSegmentMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected