trpc.group/trpc-go/trpc-go@v1.0.3/internal/report/metrics_reports.go (about)

     1  //
     2  //
     3  // Tencent is pleased to support the open source community by making tRPC available.
     4  //
     5  // Copyright (C) 2023 THL A29 Limited, a Tencent company.
     6  // All rights reserved.
     7  //
     8  // If you have downloaded a copy of the tRPC source code from Tencent,
     9  // please note that tRPC source code is licensed under the  Apache 2.0 License,
    10  // A copy of the Apache 2.0 License is included in this file.
    11  //
    12  //
    13  
    14  // Package report reports the statistics of the framework.
    15  package report
    16  
    17  import (
    18  	"trpc.group/trpc-go/trpc-go/metrics"
    19  )
    20  
    21  // Unified all metrics report inside the framework. Every property starts with "trpc.".
    22  var (
    23  	// -----------------------------server----------------------------- //
    24  	// service starts successfully.
    25  	ServiceStart = metrics.Counter("trpc.ServiceStart")
    26  	// service is not configured with codec, protocol field must be filled in framework configuration.
    27  	ServerCodecEmpty = metrics.Counter("trpc.ServerCodecEmpty")
    28  	// service handle function fails, only happens when encode fails and is not able to reply.
    29  	ServiceHandleFail = metrics.Counter("trpc.ServiceHandleFail")
    30  	// fails to decode request, usually happens when the package is illegal.
    31  	ServiceCodecDecodeFail = metrics.Counter("trpc.ServiceCodecDecodeFail")
    32  	// fails to encode reply, usually happens when there is a bug in the codec plugin.
    33  	ServiceCodecEncodeFail = metrics.Counter("trpc.ServiceCodecEncodeFail")
    34  	// invalid handle rpc name, usually happens when the caller fills an incorrect parameter.
    35  	ServiceHandleRPCNameInvalid = metrics.Counter("trpc.ServiceHandleRpcNameInvalid")
    36  	// fails to unmarshal the body, usually happens when the pb file is not agreed between the caller and callee.
    37  	ServiceCodecUnmarshalFail = metrics.Counter("trpc.ServiceCodecUnmarshalFail")
    38  	// fails to marshal the body.
    39  	ServiceCodecMarshalFail = metrics.Counter("trpc.ServiceCodecMarshalFail")
    40  	// fails to decompress the body, usually happens when the pb file is not agreed between the caller and callee,
    41  	// or the compress method is not aligned.
    42  	ServiceCodecDecompressFail = metrics.Counter("trpc.ServiceCodecDecompressFail")
    43  	// fails to compress the body.
    44  	ServiceCodecCompressFail = metrics.Counter("trpc.ServiceCodecCompressFail")
    45  
    46  	// -----------------------------transport----------------------------- //
    47  	// fails to do tcp server transport handle, usually happens when encode fails.
    48  	TCPServerTransportHandleFail = metrics.Counter("trpc.TcpServerTransportHandleFail")
    49  	// fails to do tdp server transport handle, similar to TCPServerTransportHandleFail.
    50  	UDPServerTransportHandleFail = metrics.Counter("trpc.UdpServerTransportHandleFail")
    51  	// tcp server receives EOF, happens normally by the active close of the clients,
    52  	// which occurs typically in the case of long connections.
    53  	TCPServerTransportReadEOF = metrics.Counter("trpc.TcpServerTransportReadEOF")
    54  	// tcp fails to write reply in transport, usually happens when the client has already closed the connection.
    55  	TCPServerTransportWriteFail = metrics.Counter("trpc.TcpServerTransportWriteFail")
    56  	// the request size of tcp server receives.
    57  	TCPServerTransportReceiveSize = metrics.Gauge("trpc.TcpServerTransportReceiveSize")
    58  	// the reply size of tcp server sends.
    59  	TCPServerTransportSendSize = metrics.Gauge("trpc.TcpServerTransportSendSize")
    60  	// udp fails to write reply, usually happens when the caller has already closed the connection
    61  	// because of timeout and is not listening on the port.
    62  	UDPServerTransportWriteFail = metrics.Counter("trpc.UdpServerTransportWriteFail")
    63  	// tcp long connection reaches its idle timeout and releases the connection actively.
    64  	TCPServerTransportIdleTimeout = metrics.Counter("trpc.TcpServerTransportIdleTimeout")
    65  	// tcp server fails to read the frame, usually happens when the package is illegal.
    66  	TCPServerTransportReadFail = metrics.Counter("trpc.TcpServerTransportReadFail")
    67  	// udp server fails to read the frame, usually happens when the package is illegal.
    68  	UDPServerTransportReadFail = metrics.Counter("trpc.UdpServerTransportReadFail")
    69  	// the auxiliary data after udp server has already read for a complete frame.
    70  	UDPServerTransportUnRead = metrics.Counter("trpc.UdpServerTransportUnRead")
    71  	// udp client fails to read the frame, usually happens when the package is illegal.
    72  	UDPClientTransportReadFail = metrics.Counter("trpc.UdpClientTransportReadFail")
    73  	// the auxiliary data after udp client has already read for a complete frame.
    74  	UDPClientTransportUnRead = metrics.Counter("trpc.UdpClientTransportUnRead")
    75  	// request package size received by udp server.
    76  	UDPServerTransportReceiveSize = metrics.Gauge("trpc.UdpServerTransportReceiveSize")
    77  	// response package size sent by udp server.
    78  	UDPServerTransportSendSize = metrics.Gauge("trpc.UdpServerTransportSendSize")
    79  	// receive queue of tcp goroutine pool is full, the requests are overwhelming.
    80  	TCPServerTransportJobQueueFullFail = metrics.Counter("trpc.TcpServerTransportJobQueueFullFail")
    81  	// receive queue of udp goroutine pool is full, the requests are overwhelming.
    82  	UDPServerTransportJobQueueFullFail = metrics.Counter("trpc.UdpServerTransportJobQueueFullFail")
    83  	// TCPServerAsyncGoroutineScheduleDelay is the schedule delay of goroutine pool when async is on.
    84  	// DO NOT change the name, as the overload control algorithm depends on it.
    85  	TCPServerAsyncGoroutineScheduleDelay = metrics.Gauge("trpc.TcpServerAsyncGoroutineScheduleDelay_us")
    86  
    87  	// -----------------------------log----------------------------- //
    88  	// log is dropped because the queue is full.
    89  	LogQueueDropNum = metrics.Counter("trpc.LogQueueDropNum")
    90  	// the write size of log.
    91  	LogWriteSize = metrics.Counter("trpc.LogWriteSize")
    92  	// -----------------------------client----------------------------- //
    93  	// the client fails to select the server node, usually happens when the name service is not
    94  	// configured properly, or all the nodes have been fused.
    95  	SelectNodeFail = metrics.Counter("trpc.SelectNodeFail")
    96  	// client has not configured the protocol.
    97  	ClientCodecEmpty = metrics.Counter("trpc.ClientCodecEmpty")
    98  	// fails to load client config, usually happens when the client is not configured properly.
    99  	LoadClientConfigFail = metrics.Counter("trpc.LoadClientConfigFail")
   100  	// fails to load the client filter config, usually happens when client filer array is configured with a
   101  	// filter that does not exist.
   102  	LoadClientFilterConfigFail = metrics.Counter("trpc.LoadClientFilterConfigFail")
   103  	// the request package size of tcp client.
   104  	TCPClientTransportSendSize = metrics.Gauge("trpc.TcpClientTransportSendSize")
   105  	// the response package size of tcp client.
   106  	TCPClientTransportReceiveSize = metrics.Gauge("trpc.TcpClientTransportReceiveSize")
   107  	// the request package size of udp client.
   108  	UDPClientTransportSendSize = metrics.Gauge("trpc.UdpClientTransportSendSize")
   109  	// the response package size of udp client.
   110  	UDPClientTransportReceiveSize = metrics.Gauge("trpc.UdpClientTransportReceiveSize")
   111  
   112  	// -----------------------------connection pool----------------------------- //
   113  	// new connections of the connection pool.
   114  	ConnectionPoolGetNewConnection = metrics.Counter("trpc.ConnectionPoolGetNewConnection")
   115  	// fails to get a connection from the connection pool.
   116  	ConnectionPoolGetConnectionErr = metrics.Counter("trpc.ConnectionPoolGetConnectionErr")
   117  	// the remote peer of the connection pool is closed.
   118  	ConnectionPoolRemoteErr = metrics.Counter("trpc.ConnectionPoolRemoteErr")
   119  	// the remote peer of the connection pool returns EOF.
   120  	ConnectionPoolRemoteEOF = metrics.Counter("trpc.ConnectionPoolRemoteEOF")
   121  	// the connection reaches its idle timeout.
   122  	ConnectionPoolIdleTimeout = metrics.Counter("trpc.ConnectionPoolIdleTimeout")
   123  	// the connection exceeds its lifetime.
   124  	ConnectionPoolLifetimeExceed = metrics.Counter("trpc.ConnectionPoolLifetimeExceed")
   125  	// the connection number reaches its limit.
   126  	ConnectionPoolOverLimit = metrics.Counter("trpc.ConnectionPoolOverLimit")
   127  
   128  	// -----------------------------multiplexed----------------------------- //
   129  	// fails to reconnect when multiplexed.
   130  	MultiplexedTCPReconnectErr        = metrics.Counter("trpc.MultiplexedReconnectErr")
   131  	MultiplexedTCPReconnectOnReadErr  = metrics.Counter("trpc.MultiplexedReconnectOnReadErr")
   132  	MultiplexedTCPReconnectOnWriteErr = metrics.Counter("trpc.MultiplexedReconnectOnWriteErr")
   133  
   134  	// -----------------------------other----------------------------- //
   135  	// panic number of trpc.GoAndWait.
   136  	PanicNum = metrics.Counter("trpc.PanicNum")
   137  
   138  	// -----------------------------Admin----------------------------- //
   139  	// AdminPanicNum is the panic number of admin.
   140  	AdminPanicNum = metrics.Counter("trpc.AdminPanicNum")
   141  )