Skip to content

Commit 8d8571e

Browse files
authored
stats: Improved sequencing documentation for server-side stats events and added tests. (#7885)
1 parent 0af5a16 commit 8d8571e

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

stats/stats.go

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ type RPCStats interface {
3636
IsClient() bool
3737
}
3838

39-
// Begin contains stats when an RPC attempt begins.
39+
// Begin contains stats for the start of an RPC attempt.
40+
//
41+
// - Server-side: Triggered after `InHeader`, as headers are processed
42+
// before the RPC lifecycle begins.
43+
// - Client-side: The first stats event recorded.
44+
//
4045
// FailFast is only valid if this Begin is from client side.
4146
type Begin struct {
4247
// Client is true if this Begin is from client side.
@@ -69,7 +74,7 @@ func (*PickerUpdated) IsClient() bool { return true }
6974

7075
func (*PickerUpdated) isRPCStats() {}
7176

72-
// InPayload contains the information for an incoming payload.
77+
// InPayload contains stats about an incoming payload.
7378
type InPayload struct {
7479
// Client is true if this InPayload is from client side.
7580
Client bool
@@ -98,7 +103,9 @@ func (s *InPayload) IsClient() bool { return s.Client }
98103

99104
func (s *InPayload) isRPCStats() {}
100105

101-
// InHeader contains stats when a header is received.
106+
// InHeader contains stats about header reception.
107+
//
108+
// - Server-side: The first stats event after the RPC request is received.
102109
type InHeader struct {
103110
// Client is true if this InHeader is from client side.
104111
Client bool
@@ -123,7 +130,7 @@ func (s *InHeader) IsClient() bool { return s.Client }
123130

124131
func (s *InHeader) isRPCStats() {}
125132

126-
// InTrailer contains stats when a trailer is received.
133+
// InTrailer contains stats about trailer reception.
127134
type InTrailer struct {
128135
// Client is true if this InTrailer is from client side.
129136
Client bool
@@ -139,7 +146,7 @@ func (s *InTrailer) IsClient() bool { return s.Client }
139146

140147
func (s *InTrailer) isRPCStats() {}
141148

142-
// OutPayload contains the information for an outgoing payload.
149+
// OutPayload contains stats about an outgoing payload.
143150
type OutPayload struct {
144151
// Client is true if this OutPayload is from client side.
145152
Client bool
@@ -166,7 +173,10 @@ func (s *OutPayload) IsClient() bool { return s.Client }
166173

167174
func (s *OutPayload) isRPCStats() {}
168175

169-
// OutHeader contains stats when a header is sent.
176+
// OutHeader contains stats about header transmission.
177+
//
178+
// - Client-side: Only occurs after 'Begin', as headers are always the first
179+
// thing sent on a stream.
170180
type OutHeader struct {
171181
// Client is true if this OutHeader is from client side.
172182
Client bool
@@ -189,14 +199,15 @@ func (s *OutHeader) IsClient() bool { return s.Client }
189199

190200
func (s *OutHeader) isRPCStats() {}
191201

192-
// OutTrailer contains stats when a trailer is sent.
202+
// OutTrailer contains stats about trailer transmission.
193203
type OutTrailer struct {
194204
// Client is true if this OutTrailer is from client side.
195205
Client bool
196206
// WireLength is the wire length of trailer.
197207
//
198-
// Deprecated: This field is never set. The length is not known when this message is
199-
// emitted because the trailer fields are compressed with hpack after that.
208+
// Deprecated: This field is never set. The length is not known when this
209+
// message is emitted because the trailer fields are compressed with hpack
210+
// after that.
200211
WireLength int
201212
// Trailer contains the trailer metadata sent to the client. This
202213
// field is only valid if this OutTrailer is from the server side.
@@ -208,7 +219,7 @@ func (s *OutTrailer) IsClient() bool { return s.Client }
208219

209220
func (s *OutTrailer) isRPCStats() {}
210221

211-
// End contains stats when an RPC ends.
222+
// End contains stats about RPC completion.
212223
type End struct {
213224
// Client is true if this End is from client side.
214225
Client bool
@@ -238,7 +249,7 @@ type ConnStats interface {
238249
IsClient() bool
239250
}
240251

241-
// ConnBegin contains the stats of a connection when it is established.
252+
// ConnBegin contains stats about connection establishment.
242253
type ConnBegin struct {
243254
// Client is true if this ConnBegin is from client side.
244255
Client bool
@@ -249,7 +260,7 @@ func (s *ConnBegin) IsClient() bool { return s.Client }
249260

250261
func (s *ConnBegin) isConnStats() {}
251262

252-
// ConnEnd contains the stats of a connection when it ends.
263+
// ConnEnd contains stats about connection termination.
253264
type ConnEnd struct {
254265
// Client is true if this ConnEnd is from client side.
255266
Client bool

0 commit comments

Comments
 (0)