github.com/metaworking/channeld@v0.7.3/pkg/channeld/metrics.go (about) 1 package channeld 2 3 import ( 4 "github.com/prometheus/client_golang/prometheus" 5 ) 6 7 var logNum = prometheus.NewCounterVec( 8 prometheus.CounterOpts{ 9 Name: "logs", 10 Help: "Number of logs", 11 }, 12 []string{"level"}, 13 ) 14 15 var msgReceived = prometheus.NewCounterVec( 16 prometheus.CounterOpts{ 17 Name: "messages_in", 18 Help: "Received messages", 19 }, 20 []string{"connType" /*, "channel", "msgType"*/}, 21 ) 22 23 var msgSent = prometheus.NewCounterVec( 24 prometheus.CounterOpts{ 25 Name: "messages_out", 26 Help: "Sent messages", 27 }, 28 []string{"connType" /*, "channel", "msgType"*/}, 29 ) 30 var packetReceived = prometheus.NewCounterVec( 31 prometheus.CounterOpts{ 32 Name: "packets_in", 33 Help: "Received packets", 34 }, 35 []string{"connType"}, 36 ) 37 38 var packetSent = prometheus.NewCounterVec( 39 prometheus.CounterOpts{ 40 Name: "packets_out", 41 Help: "Sent packets", 42 }, 43 []string{"connType"}, 44 ) 45 46 var packetDropped = prometheus.NewCounterVec( 47 prometheus.CounterOpts{ 48 Name: "packets_drop", 49 Help: "Dropped packets", 50 }, 51 []string{"connType"}, 52 ) 53 54 var fragmentedPacketCount = prometheus.NewCounterVec( 55 prometheus.CounterOpts{ 56 Name: "packets_frag", 57 Help: "Fragmented packets", 58 }, 59 []string{"connType"}, 60 ) 61 62 var combinedPacketCount = prometheus.NewCounterVec( 63 prometheus.CounterOpts{ 64 Name: "packets_comb", 65 Help: "Combined packets", 66 }, 67 []string{"connType"}, 68 ) 69 70 var bytesReceived = prometheus.NewCounterVec( 71 prometheus.CounterOpts{ 72 Name: "bytes_in", 73 Help: "Received bytes", 74 }, 75 []string{"connType"}, 76 ) 77 78 var bytesSent = prometheus.NewCounterVec( 79 prometheus.CounterOpts{ 80 Name: "bytes_out", 81 Help: "Sent bytes", 82 }, 83 []string{"connType"}, 84 ) 85 86 var connectionNum = prometheus.NewGaugeVec( 87 prometheus.GaugeOpts{ 88 Name: "connection_num", 89 Help: "Number of connections", 90 }, 91 []string{"type"}, 92 ) 93 94 var channelNum = prometheus.NewGaugeVec( 95 prometheus.GaugeOpts{ 96 Name: "channel_num", 97 Help: "Number of channels", 98 }, 99 []string{"type"}, 100 ) 101 102 var channelTickDuration = prometheus.NewGaugeVec( 103 prometheus.GaugeOpts{ 104 Name: "channel_tick_duration", 105 Help: "How long it takes to Channel.Tick()", 106 }, 107 []string{"type"}, 108 ) 109 var connectionClosed = prometheus.NewCounterVec( 110 prometheus.CounterOpts{ 111 Name: "connection_closed", 112 Help: "connection closed", 113 }, 114 []string{"connType"}, 115 ) 116 117 func InitMetrics() { 118 prometheus.MustRegister(logNum) 119 prometheus.MustRegister(msgReceived) 120 prometheus.MustRegister(msgSent) 121 prometheus.MustRegister(packetReceived) 122 prometheus.MustRegister(packetSent) 123 prometheus.MustRegister(packetDropped) 124 prometheus.MustRegister(fragmentedPacketCount) 125 prometheus.MustRegister(combinedPacketCount) 126 prometheus.MustRegister(bytesReceived) 127 prometheus.MustRegister(bytesSent) 128 prometheus.MustRegister(connectionNum) 129 prometheus.MustRegister(channelNum) 130 prometheus.MustRegister(channelTickDuration) 131 prometheus.MustRegister(connectionClosed) 132 }