3 * Copyright 2016 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 // 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.
21 // All APIs are experimental.
22 package stats // import "google.golang.org/grpc/stats"
29 // RPCStats contains stats information about RPCs.
30 type RPCStats interface {
32 // IsClient returns true if this RPCStats is from client side.
36 // Begin contains stats when an RPC begins.
37 // FailFast is only valid if this Begin is from client side.
39 // Client is true if this Begin is from client side.
41 // BeginTime is the time when the RPC begins.
43 // FailFast indicates if this RPC is failfast.
47 // IsClient indicates if the stats information is from client side.
48 func (s *Begin) IsClient() bool { return s.Client }
50 func (s *Begin) isRPCStats() {}
52 // InPayload contains the information for an incoming payload.
53 type InPayload struct {
54 // Client is true if this InPayload is from client side.
56 // Payload is the payload with original type.
58 // Data is the serialized message payload.
60 // Length is the length of uncompressed data.
62 // WireLength is the length of data on wire (compressed, signed, encrypted).
64 // RecvTime is the time when the payload is received.
68 // IsClient indicates if the stats information is from client side.
69 func (s *InPayload) IsClient() bool { return s.Client }
71 func (s *InPayload) isRPCStats() {}
73 // InHeader contains stats when a header is received.
74 type InHeader struct {
75 // Client is true if this InHeader is from client side.
77 // WireLength is the wire length of header.
80 // The following fields are valid only if Client is false.
81 // FullMethod is the full RPC method string, i.e., /package.service/method.
83 // RemoteAddr is the remote address of the corresponding connection.
85 // LocalAddr is the local address of the corresponding connection.
87 // Compression is the compression algorithm used for the RPC.
91 // IsClient indicates if the stats information is from client side.
92 func (s *InHeader) IsClient() bool { return s.Client }
94 func (s *InHeader) isRPCStats() {}
96 // InTrailer contains stats when a trailer is received.
97 type InTrailer struct {
98 // Client is true if this InTrailer is from client side.
100 // WireLength is the wire length of trailer.
104 // IsClient indicates if the stats information is from client side.
105 func (s *InTrailer) IsClient() bool { return s.Client }
107 func (s *InTrailer) isRPCStats() {}
109 // OutPayload contains the information for an outgoing payload.
110 type OutPayload struct {
111 // Client is true if this OutPayload is from client side.
113 // Payload is the payload with original type.
115 // Data is the serialized message payload.
117 // Length is the length of uncompressed data.
119 // WireLength is the length of data on wire (compressed, signed, encrypted).
121 // SentTime is the time when the payload is sent.
125 // IsClient indicates if this stats information is from client side.
126 func (s *OutPayload) IsClient() bool { return s.Client }
128 func (s *OutPayload) isRPCStats() {}
130 // OutHeader contains stats when a header is sent.
131 type OutHeader struct {
132 // Client is true if this OutHeader is from client side.
134 // WireLength is the wire length of header.
137 // The following fields are valid only if Client is true.
138 // FullMethod is the full RPC method string, i.e., /package.service/method.
140 // RemoteAddr is the remote address of the corresponding connection.
142 // LocalAddr is the local address of the corresponding connection.
144 // Compression is the compression algorithm used for the RPC.
148 // IsClient indicates if this stats information is from client side.
149 func (s *OutHeader) IsClient() bool { return s.Client }
151 func (s *OutHeader) isRPCStats() {}
153 // OutTrailer contains stats when a trailer is sent.
154 type OutTrailer struct {
155 // Client is true if this OutTrailer is from client side.
157 // WireLength is the wire length of trailer.
161 // IsClient indicates if this stats information is from client side.
162 func (s *OutTrailer) IsClient() bool { return s.Client }
164 func (s *OutTrailer) isRPCStats() {}
166 // End contains stats when an RPC ends.
168 // Client is true if this End is from client side.
170 // EndTime is the time when the RPC ends.
172 // Error is the error the RPC ended with. It is an error generated from
173 // status.Status and can be converted back to status.Status using
174 // status.FromError if non-nil.
178 // IsClient indicates if this is from client side.
179 func (s *End) IsClient() bool { return s.Client }
181 func (s *End) isRPCStats() {}
183 // ConnStats contains stats information about connections.
184 type ConnStats interface {
186 // IsClient returns true if this ConnStats is from client side.
190 // ConnBegin contains the stats of a connection when it is established.
191 type ConnBegin struct {
192 // Client is true if this ConnBegin is from client side.
196 // IsClient indicates if this is from client side.
197 func (s *ConnBegin) IsClient() bool { return s.Client }
199 func (s *ConnBegin) isConnStats() {}
201 // ConnEnd contains the stats of a connection when it ends.
202 type ConnEnd struct {
203 // Client is true if this ConnEnd is from client side.
207 // IsClient indicates if this is from client side.
208 func (s *ConnEnd) IsClient() bool { return s.Client }
210 func (s *ConnEnd) isConnStats() {}