diff options
Diffstat (limited to 'vendor/google.golang.org/grpc/stats/stats.go')
-rw-r--r-- | vendor/google.golang.org/grpc/stats/stats.go | 89 |
1 files changed, 87 insertions, 2 deletions
diff --git a/vendor/google.golang.org/grpc/stats/stats.go b/vendor/google.golang.org/grpc/stats/stats.go index 338a3a7..84f77da 100644 --- a/vendor/google.golang.org/grpc/stats/stats.go +++ b/vendor/google.golang.org/grpc/stats/stats.go | |||
@@ -16,12 +16,15 @@ | |||
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | 18 | ||
19 | //go:generate protoc --go_out=plugins=grpc:. grpc_testing/test.proto | ||
20 | |||
19 | // Package stats is for collecting and reporting various network and RPC stats. | 21 | // Package stats is for collecting and reporting various network and RPC stats. |
20 | // This package is for monitoring purpose only. All fields are read-only. | 22 | // This package is for monitoring purpose only. All fields are read-only. |
21 | // All APIs are experimental. | 23 | // All APIs are experimental. |
22 | package stats // import "google.golang.org/grpc/stats" | 24 | package stats // import "google.golang.org/grpc/stats" |
23 | 25 | ||
24 | import ( | 26 | import ( |
27 | "context" | ||
25 | "net" | 28 | "net" |
26 | "time" | 29 | "time" |
27 | ) | 30 | ) |
@@ -131,8 +134,6 @@ func (s *OutPayload) isRPCStats() {} | |||
131 | type OutHeader struct { | 134 | type OutHeader struct { |
132 | // Client is true if this OutHeader is from client side. | 135 | // Client is true if this OutHeader is from client side. |
133 | Client bool | 136 | Client bool |
134 | // WireLength is the wire length of header. | ||
135 | WireLength int | ||
136 | 137 | ||
137 | // The following fields are valid only if Client is true. | 138 | // The following fields are valid only if Client is true. |
138 | // FullMethod is the full RPC method string, i.e., /package.service/method. | 139 | // FullMethod is the full RPC method string, i.e., /package.service/method. |
@@ -167,6 +168,8 @@ func (s *OutTrailer) isRPCStats() {} | |||
167 | type End struct { | 168 | type End struct { |
168 | // Client is true if this End is from client side. | 169 | // Client is true if this End is from client side. |
169 | Client bool | 170 | Client bool |
171 | // BeginTime is the time when the RPC began. | ||
172 | BeginTime time.Time | ||
170 | // EndTime is the time when the RPC ends. | 173 | // EndTime is the time when the RPC ends. |
171 | EndTime time.Time | 174 | EndTime time.Time |
172 | // Error is the error the RPC ended with. It is an error generated from | 175 | // Error is the error the RPC ended with. It is an error generated from |
@@ -208,3 +211,85 @@ type ConnEnd struct { | |||
208 | func (s *ConnEnd) IsClient() bool { return s.Client } | 211 | func (s *ConnEnd) IsClient() bool { return s.Client } |
209 | 212 | ||
210 | func (s *ConnEnd) isConnStats() {} | 213 | func (s *ConnEnd) isConnStats() {} |
214 | |||
215 | type incomingTagsKey struct{} | ||
216 | type outgoingTagsKey struct{} | ||
217 | |||
218 | // SetTags attaches stats tagging data to the context, which will be sent in | ||
219 | // the outgoing RPC with the header grpc-tags-bin. Subsequent calls to | ||
220 | // SetTags will overwrite the values from earlier calls. | ||
221 | // | ||
222 | // NOTE: this is provided only for backward compatibility with existing clients | ||
223 | // and will likely be removed in an upcoming release. New uses should transmit | ||
224 | // this type of data using metadata with a different, non-reserved (i.e. does | ||
225 | // not begin with "grpc-") header name. | ||
226 | func SetTags(ctx context.Context, b []byte) context.Context { | ||
227 | return context.WithValue(ctx, outgoingTagsKey{}, b) | ||
228 | } | ||
229 | |||
230 | // Tags returns the tags from the context for the inbound RPC. | ||
231 | // | ||
232 | // NOTE: this is provided only for backward compatibility with existing clients | ||
233 | // and will likely be removed in an upcoming release. New uses should transmit | ||
234 | // this type of data using metadata with a different, non-reserved (i.e. does | ||
235 | // not begin with "grpc-") header name. | ||
236 | func Tags(ctx context.Context) []byte { | ||
237 | b, _ := ctx.Value(incomingTagsKey{}).([]byte) | ||
238 | return b | ||
239 | } | ||
240 | |||
241 | // SetIncomingTags attaches stats tagging data to the context, to be read by | ||
242 | // the application (not sent in outgoing RPCs). | ||
243 | // | ||
244 | // This is intended for gRPC-internal use ONLY. | ||
245 | func SetIncomingTags(ctx context.Context, b []byte) context.Context { | ||
246 | return context.WithValue(ctx, incomingTagsKey{}, b) | ||
247 | } | ||
248 | |||
249 | // OutgoingTags returns the tags from the context for the outbound RPC. | ||
250 | // | ||
251 | // This is intended for gRPC-internal use ONLY. | ||
252 | func OutgoingTags(ctx context.Context) []byte { | ||
253 | b, _ := ctx.Value(outgoingTagsKey{}).([]byte) | ||
254 | return b | ||
255 | } | ||
256 | |||
257 | type incomingTraceKey struct{} | ||
258 | type outgoingTraceKey struct{} | ||
259 | |||
260 | // SetTrace attaches stats tagging data to the context, which will be sent in | ||
261 | // the outgoing RPC with the header grpc-trace-bin. Subsequent calls to | ||
262 | // SetTrace will overwrite the values from earlier calls. | ||
263 | // | ||
264 | // NOTE: this is provided only for backward compatibility with existing clients | ||
265 | // and will likely be removed in an upcoming release. New uses should transmit | ||
266 | // this type of data using metadata with a different, non-reserved (i.e. does | ||
267 | // not begin with "grpc-") header name. | ||
268 | func SetTrace(ctx context.Context, b []byte) context.Context { | ||
269 | return context.WithValue(ctx, outgoingTraceKey{}, b) | ||
270 | } | ||
271 | |||
272 | // Trace returns the trace from the context for the inbound RPC. | ||
273 | // | ||
274 | // NOTE: this is provided only for backward compatibility with existing clients | ||
275 | // and will likely be removed in an upcoming release. New uses should transmit | ||
276 | // this type of data using metadata with a different, non-reserved (i.e. does | ||
277 | // not begin with "grpc-") header name. | ||
278 | func Trace(ctx context.Context) []byte { | ||
279 | b, _ := ctx.Value(incomingTraceKey{}).([]byte) | ||
280 | return b | ||
281 | } | ||
282 | |||
283 | // SetIncomingTrace attaches stats tagging data to the context, to be read by | ||
284 | // the application (not sent in outgoing RPCs). It is intended for | ||
285 | // gRPC-internal use. | ||
286 | func SetIncomingTrace(ctx context.Context, b []byte) context.Context { | ||
287 | return context.WithValue(ctx, incomingTraceKey{}, b) | ||
288 | } | ||
289 | |||
290 | // OutgoingTrace returns the trace from the context for the outbound RPC. It is | ||
291 | // intended for gRPC-internal use. | ||
292 | func OutgoingTrace(ctx context.Context) []byte { | ||
293 | b, _ := ctx.Value(outgoingTraceKey{}).([]byte) | ||
294 | return b | ||
295 | } | ||