Skip to content

Commit

Permalink
swarm: use the prometheus namespace option
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jan 26, 2023
1 parent 1056e17 commit f2746ea
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions p2p/net/swarm/swarm_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,56 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

const metricNamespace = "libp2p_swarm_"
const metricNamespace = "libp2p_swarm"

var (
connsOpened = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: metricNamespace + "connections_opened_total",
Help: "Connections Opened",
Namespace: metricNamespace,
Name: "connections_opened_total",
Help: "Connections Opened",
},
[]string{"dir", "transport", "security", "muxer"},
)
keyTypes = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: metricNamespace + "key_types_total",
Help: "key type",
Namespace: metricNamespace,
Name: "key_types_total",
Help: "key type",
},
[]string{"dir", "key_type"},
)
connsClosed = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: metricNamespace + "connections_closed_total",
Help: "Connections Closed",
Namespace: metricNamespace,
Name: "connections_closed_total",
Help: "Connections Closed",
},
[]string{"dir", "transport", "security", "muxer"},
)
dialError = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: metricNamespace + "dial_errors_total",
Help: "Dial Error",
Namespace: metricNamespace,
Name: "dial_errors_total",
Help: "Dial Error",
},
[]string{"transport", "error"},
)
connDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: metricNamespace + "connection_duration_seconds",
Help: "Duration of a Connection",
Buckets: prometheus.ExponentialBuckets(1.0/16, 2, 25), // up to 24 days
Namespace: metricNamespace,
Name: "connection_duration_seconds",
Help: "Duration of a Connection",
Buckets: prometheus.ExponentialBuckets(1.0/16, 2, 25), // up to 24 days
},
[]string{"dir", "transport", "security", "muxer"},
)
connHandshakeLatency = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: metricNamespace + "handshake_latency_seconds",
Help: "Duration of the libp2p Handshake",
Buckets: prometheus.ExponentialBuckets(0.001, 1.3, 35),
Namespace: metricNamespace,
Name: "handshake_latency_seconds",
Help: "Duration of the libp2p Handshake",
Buckets: prometheus.ExponentialBuckets(0.001, 1.3, 35),
},
[]string{"transport", "security", "muxer"},
)
Expand Down

0 comments on commit f2746ea

Please sign in to comment.