-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add handshake protocol messages metrics
- Loading branch information
mrekucci
committed
Sep 14, 2021
1 parent
dad0c45
commit f6a22ab
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2021 The Swarm Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package handshake | ||
|
||
import ( | ||
m "github.com/ethersphere/bee/pkg/metrics" | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
// metrics groups handshake related prometheus counters. | ||
type metrics struct { | ||
SynRx prometheus.Counter | ||
SynRxFailed prometheus.Counter | ||
SynAckTx prometheus.Counter | ||
SynAckTxFailed prometheus.Counter | ||
AckRx prometheus.Counter | ||
AckRxFailed prometheus.Counter | ||
} | ||
|
||
// newMetrics is a convenient constructor for creating new metrics. | ||
func newMetrics() metrics { | ||
const subsystem = "handshake" | ||
|
||
return metrics{ | ||
SynRx: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "syn_rx", | ||
Help: "The number of syn messages that were successfully read.", | ||
}), | ||
SynRxFailed: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "syn_rx_failed", | ||
Help: "The number of syn messages that were unsuccessfully read.", | ||
}), | ||
SynAckTx: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "syn_ack_tx", | ||
Help: "The number of syn-ack messages that were successfully written.", | ||
}), | ||
SynAckTxFailed: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "syn_ack_tx_failed", | ||
Help: "The number of syn-ack messages that were unsuccessfully written.", | ||
}), | ||
AckRx: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "ack_rx", | ||
Help: "The number of ack messages that were successfully read.", | ||
}), | ||
AckRxFailed: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "ack_rx_failed", | ||
Help: "The number of ack messages that were unsuccessfully read.", | ||
}), | ||
} | ||
} | ||
|
||
// Metrics returns set of prometheus collectors. | ||
func (s *Service) Metrics() []prometheus.Collector { | ||
return m.PrometheusCollectorsFromFields(s.metrics) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters