change stats comments

This commit is contained in:
Menghan Li
2016-11-04 10:44:23 -07:00
parent e478486783
commit 8a126b020f
4 changed files with 37 additions and 37 deletions

View File

@ -48,13 +48,13 @@ import (
// RPCStats contains stats information about RPCs. // RPCStats contains stats information about RPCs.
// All stats types in this package implements this interface. // All stats types in this package implements this interface.
type RPCStats interface { type RPCStats interface {
// IsClient indicates if the stats is a client stats. // IsClient returns true if this RPCStats is from client side.
IsClient() bool IsClient() bool
} }
// InPayload contains the information for a incoming payload. // InPayload contains the information for an incoming payload.
type InPayload struct { type InPayload struct {
// Client indicates if this stats is a client stats. // Client is true if this InPayload is from client side.
Client bool Client bool
// Payload is the payload with original type. // Payload is the payload with original type.
Payload interface{} Payload interface{}
@ -68,19 +68,19 @@ type InPayload struct {
RecvTime time.Time RecvTime time.Time
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *InPayload) IsClient() bool { return s.Client } func (s *InPayload) IsClient() bool { return s.Client }
// InHeader indicates a header is received. // InHeader contains stats when a header is received.
// Method, addresses and Encryption are only valid if Client is false. // FullMethod, addresses and Encryption are only valid if Client is false.
type InHeader struct { type InHeader struct {
// Client indicates if this stats is a client stats. // Client is true if this InHeader is from client side.
Client bool Client bool
// WireLength is the wire length of header. // WireLength is the wire length of header.
WireLength int WireLength int
// Method is the full RPC method string, i.e., /package.service/method. // FullMethod is the full RPC method string, i.e., /package.service/method.
Method string FullMethod string
// RemoteAddr is the remote address of the corresponding connection. // RemoteAddr is the remote address of the corresponding connection.
RemoteAddr net.Addr RemoteAddr net.Addr
// LocalAddr is the local address of the corresponding connection. // LocalAddr is the local address of the corresponding connection.
@ -89,23 +89,23 @@ type InHeader struct {
Encryption string Encryption string
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *InHeader) IsClient() bool { return s.Client } func (s *InHeader) IsClient() bool { return s.Client }
// InTrailer indicates a trailer is received. // InTrailer contains stats when a trailer is received.
type InTrailer struct { type InTrailer struct {
// Client indicates if this stats is a client stats. // Client is true if this InTrailer is from client side.
Client bool Client bool
// WireLength is the wire length of header. // WireLength is the wire length of trailer.
WireLength int WireLength int
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *InTrailer) IsClient() bool { return s.Client } func (s *InTrailer) IsClient() bool { return s.Client }
// OutPayload contains the information for a outgoing payload. // OutPayload contains the information for an outgoing payload.
type OutPayload struct { type OutPayload struct {
// Client indicates if this stats is a client stats. // Client is true if this OutPayload is from client side.
Client bool Client bool
// Payload is the payload with original type. // Payload is the payload with original type.
Payload interface{} Payload interface{}
@ -119,52 +119,52 @@ type OutPayload struct {
SentTime time.Time SentTime time.Time
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *OutPayload) IsClient() bool { return s.Client } func (s *OutPayload) IsClient() bool { return s.Client }
// OutHeader indicates a header is sent. // OutHeader contains stats when a header is sent.
// Method, addresses and Encryption are only valid if Client is true. // FullMethod, addresses, Encryption and FailFast are only valid if Client is true.
type OutHeader struct { type OutHeader struct {
// Client indicates if this stats is a client stats. // Client is true if this OutHeader is from client side.
Client bool Client bool
// WireLength is the wire length of header. // WireLength is the wire length of header.
WireLength int WireLength int
// Method is the full RPC method string, i.e., /package.service/method. // FullMethod is the full RPC method string, i.e., /package.service/method.
Method string FullMethod string
// RemoteAddr is the remote address of the corresponding connection. // RemoteAddr is the remote address of the corresponding connection.
RemoteAddr net.Addr RemoteAddr net.Addr
// LocalAddr is the local address of the corresponding connection. // LocalAddr is the local address of the corresponding connection.
LocalAddr net.Addr LocalAddr net.Addr
// Encryption is encrypt method used in the RPC. // Encryption is encrypt method used in the RPC.
Encryption string Encryption string
// Failfast indicates if this RPC is failfast. // FailFast indicates if this RPC is failfast.
FailFast bool FailFast bool
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *OutHeader) IsClient() bool { return s.Client } func (s *OutHeader) IsClient() bool { return s.Client }
// OutTrailer indicates a trailer is sent. // OutTrailer contains stats when a trailer is sent.
type OutTrailer struct { type OutTrailer struct {
// Client indicates if this stats is a client stats. // Client is true if this OutTrailer is from client side.
Client bool Client bool
// WireLength is the wire length of header. // WireLength is the wire length of trailer.
WireLength int WireLength int
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *OutTrailer) IsClient() bool { return s.Client } func (s *OutTrailer) IsClient() bool { return s.Client }
// RPCErr indicates an error happens. // RPCErr contains stats when an error happens.
type RPCErr struct { type RPCErr struct {
// Client indicates if this stats is a client stats. // Client is true if this RPCErr is from client side.
Client bool Client bool
// Error is the error just happened. Its type is gRPC error. // Error is the error just happened. Its type is gRPC error.
Error error Error error
} }
// IsClient indicates if the stats is a client stats. // IsClient indicates if this is from client side.
func (s *RPCErr) IsClient() bool { return s.Client } func (s *RPCErr) IsClient() bool { return s.Client }
var ( var (

View File

@ -333,8 +333,8 @@ func checkInHeader(t *testing.T, d *gotData, e *expectedData) {
t.Fatalf("st.Lenght = 0, want > 0") t.Fatalf("st.Lenght = 0, want > 0")
} }
if !d.client { if !d.client {
if st.Method != e.method { if st.FullMethod != e.method {
t.Fatalf("st.Method = %s, want %v", st.Method, e.method) t.Fatalf("st.FullMethod = %s, want %v", st.FullMethod, e.method)
} }
if st.LocalAddr.String() != e.serverAddr { if st.LocalAddr.String() != e.serverAddr {
t.Fatalf("st.LocalAddr = %v, want %v", st.LocalAddr, e.serverAddr) t.Fatalf("st.LocalAddr = %v, want %v", st.LocalAddr, e.serverAddr)
@ -426,8 +426,8 @@ func checkOutHeader(t *testing.T, d *gotData, e *expectedData) {
t.Fatalf("st.Lenght = 0, want > 0") t.Fatalf("st.Lenght = 0, want > 0")
} }
if d.client { if d.client {
if st.Method != e.method { if st.FullMethod != e.method {
t.Fatalf("st.Method = %s, want %v", st.Method, e.method) t.Fatalf("st.FullMethod = %s, want %v", st.FullMethod, e.method)
} }
if st.RemoteAddr.String() != e.serverAddr { if st.RemoteAddr.String() != e.serverAddr {
t.Fatalf("st.LocalAddr = %v, want %v", st.LocalAddr, e.serverAddr) t.Fatalf("st.LocalAddr = %v, want %v", st.LocalAddr, e.serverAddr)

View File

@ -453,7 +453,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
outHeader := &stats.OutHeader{ outHeader := &stats.OutHeader{
Client: true, Client: true,
WireLength: bufLen, WireLength: bufLen,
Method: callHdr.Method, FullMethod: callHdr.Method,
RemoteAddr: t.RemoteAddr(), RemoteAddr: t.RemoteAddr(),
LocalAddr: t.LocalAddr(), LocalAddr: t.LocalAddr(),
Encryption: callHdr.SendCompress, Encryption: callHdr.SendCompress,

View File

@ -237,7 +237,7 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
} }
if stats.On() { if stats.On() {
inHeader := &stats.InHeader{ inHeader := &stats.InHeader{
Method: s.method, FullMethod: s.method,
RemoteAddr: t.conn.RemoteAddr(), RemoteAddr: t.conn.RemoteAddr(),
LocalAddr: t.conn.LocalAddr(), LocalAddr: t.conn.LocalAddr(),
Encryption: s.recvCompress, Encryption: s.recvCompress,