@@ -20,12 +20,11 @@ const (
2020)
2121
2222var (
23+ // TCP/WS/WSS only: bee does not register QUIC today.
2324 transportLabelValues = []string {
2425 bzz .TransportTCP .String (),
2526 bzz .TransportWS .String (),
2627 bzz .TransportWSS .String (),
27- bzz .TransportQUICV1 .String (),
28- bzz .TransportQUIC .String (),
2928 bzz .TransportUnknown .String (),
3029 }
3130 publicLabelValues = []string {"true" , "false" }
@@ -56,14 +55,16 @@ func newMetrics() metrics {
5655 transportHelp := "The 'transport' label is one of: " + strings .Join (transportLabelValues , ", " )
5756 publicHelp := "The 'public' label is one of: " + strings .Join (publicLabelValues , ", " ) + " (true = public remote multiaddr)."
5857
58+ connectionLabels := []string {connectionTransportLabelName , connectionPublicLabelName }
59+
5960 createdConnectionCount := prometheus .NewCounterVec (
6061 prometheus.CounterOpts {
6162 Namespace : m .Namespace ,
6263 Subsystem : subsystem ,
6364 Name : "created_connection_count" ,
64- Help : "Number of initiated outgoing libp2p connections. " + transportHelp ,
65+ Help : "Number of initiated outgoing libp2p connections. " + transportHelp + " " + publicHelp ,
6566 },
66- [] string { connectionTransportLabelName } ,
67+ connectionLabels ,
6768 )
6869
6970 handledConnectionCount := prometheus .NewCounterVec (
@@ -73,14 +74,14 @@ func newMetrics() metrics {
7374 Name : "handled_connection_count" ,
7475 Help : "Number of handled incoming libp2p connections. " + transportHelp + " " + publicHelp ,
7576 },
76- [] string { connectionTransportLabelName , connectionPublicLabelName } ,
77+ connectionLabels ,
7778 )
7879
7980 // Ensure all expected label value combinations exist as 0-valued series,
8081 // so Grafana shows a flat line instead of "No Data".
8182 for _ , transport := range transportLabelValues {
82- createdConnectionCount .WithLabelValues (transport ).Add (0 )
8383 for _ , public := range publicLabelValues {
84+ createdConnectionCount .WithLabelValues (transport , public ).Add (0 )
8485 handledConnectionCount .WithLabelValues (transport , public ).Add (0 )
8586 }
8687 }
@@ -164,21 +165,24 @@ func newMetrics() metrics {
164165}
165166
166167func (m metrics ) incCreatedConnection (addr ma.Multiaddr ) {
167- m .CreatedConnectionCount .WithLabelValues (connectionTransportLabel (addr )).Inc ()
168+ m .CreatedConnectionCount .WithLabelValues (connectionTransportLabel (addr ), connectionPublicLabel ( addr ) ).Inc ()
168169}
169170
170171func (m metrics ) observeHandledConnection (addr ma.Multiaddr ) {
171- public := "false"
172- if manet .IsPublicAddr (addr ) {
173- public = "true"
174- }
175- m .HandledConnectionCount .WithLabelValues (connectionTransportLabel (addr ), public ).Inc ()
172+ m .HandledConnectionCount .WithLabelValues (connectionTransportLabel (addr ), connectionPublicLabel (addr )).Inc ()
176173}
177174
178175func connectionTransportLabel (addr ma.Multiaddr ) string {
179176 return bzz .ClassifyTransport (addr ).String ()
180177}
181178
179+ func connectionPublicLabel (addr ma.Multiaddr ) string {
180+ if manet .IsPublicAddr (addr ) {
181+ return "true"
182+ }
183+ return "false"
184+ }
185+
182186func (s * Service ) Metrics () []prometheus.Collector {
183187 collectors := append (m .PrometheusCollectorsFromFields (s .metrics ), s .handshakeService .Metrics ()... )
184188 if mc , ok := s .reacher .(interface { Metrics () []prometheus.Collector }); ok {
0 commit comments