Skip to content

Commit

Permalink
fix: update metric names to follow prometheus naming guide (libp2p#228)
Browse files Browse the repository at this point in the history
The [Prometheus metric naming guidelines](https://prometheus.io/docs/practices/naming/) say they should have suffixes like `_total` for unit-less counts and `_info` for metadata.
  • Loading branch information
achingbrain authored Nov 17, 2022
1 parent 3aadf43 commit 24c5b37
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ export class TCPListener extends EventEmitter<ListenerEvents> implements Listene
addr = `${address.address}:${address.port}`
}

context.metrics?.registerMetric(`libp2p_tcp_connections_${addr}_count`, {
context.metrics?.registerMetric(`libp2p_tcp_connections_${addr}_total`, {
help: 'Current active connections in TCP listener',
calculate: () => {
return this.connections.size
}
})

this.metrics = {
status: context.metrics.registerMetric(`libp2p_tcp_${addr}_server_status`, {
status: context.metrics.registerMetric(`libp2p_tcp_${addr}_server_status_info`, {
help: 'Current status of the TCP server'
}),
errors: context.metrics.registerCounterGroup(`libp2p_tcp_${addr}_server_errors_total`, {
label: 'error',
help: 'Total count of TCP listener errors by error type'
}),
events: context.metrics.registerCounterGroup(`libp2p_tcp_$${addr}_socket_events`, {
events: context.metrics.registerCounterGroup(`libp2p_tcp_${addr}_socket_events_total`, {
label: 'event',
help: 'Total count of TCP socket events by event'
})
Expand Down

0 comments on commit 24c5b37

Please sign in to comment.