Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
fb31f446
Commit
fb31f446
authored
Nov 16, 2015
by
Jeromy
Browse files
remove prometheus dep
parent
9848eea3
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/net/swarm/swarm.go
View file @
fb31f446
...
...
@@ -24,7 +24,6 @@ import (
mafilter
"QmYhewVqJhkgEsm3AYVUbpT14q2P9V4Xb7np9JXKua6y7A/multiaddr-filter"
context
"QmacZi9WygGK7Me8mH53pypyscHzU386aUZXpr28GZgUct/context"
ma
"QmbWxL1aXQhBjc1XGjGF1f2KGBMCBYSuT2ThA8YXnXJK83/go-multiaddr"
prom
"github.com/prometheus/client_golang/prometheus"
logging
"QmWRypnfEwrgH4k93KEHN5hng7VjKYkWmzDYRuTZeh2Mgh/go-log"
)
...
...
@@ -33,13 +32,6 @@ var log = logging.Logger("swarm2")
var
PSTransport
pst
.
Transport
var
peersTotal
=
prom
.
NewGaugeVec
(
prom
.
GaugeOpts
{
Namespace
:
"ipfs"
,
Subsystem
:
"p2p"
,
Name
:
"peers_total"
,
Help
:
"Number of connected peers"
,
},
[]
string
{
"peer_id"
})
func
init
()
{
PSTransport
=
psmss
.
NewTransport
()
}
...
...
@@ -109,10 +101,6 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
s
.
proc
=
goprocessctx
.
WithContextAndTeardown
(
ctx
,
s
.
teardown
)
s
.
SetConnHandler
(
nil
)
// make sure to setup our own conn handler.
// setup swarm metrics
prom
.
MustRegisterOrGet
(
peersTotal
)
s
.
Notify
((
*
metricsNotifiee
)(
s
))
err
=
s
.
setupInterfaces
(
listenAddrs
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -321,22 +309,3 @@ func (n *ps2netNotifee) OpenedStream(s *ps.Stream) {
func
(
n
*
ps2netNotifee
)
ClosedStream
(
s
*
ps
.
Stream
)
{
n
.
not
.
ClosedStream
(
n
.
net
,
inet
.
Stream
((
*
Stream
)(
s
)))
}
type
metricsNotifiee
Swarm
func
(
nn
*
metricsNotifiee
)
Connected
(
n
inet
.
Network
,
v
inet
.
Conn
)
{
peersTotalGauge
(
n
.
LocalPeer
())
.
Set
(
float64
(
len
(
n
.
Conns
())))
}
func
(
nn
*
metricsNotifiee
)
Disconnected
(
n
inet
.
Network
,
v
inet
.
Conn
)
{
peersTotalGauge
(
n
.
LocalPeer
())
.
Set
(
float64
(
len
(
n
.
Conns
())))
}
func
(
nn
*
metricsNotifiee
)
OpenedStream
(
n
inet
.
Network
,
v
inet
.
Stream
)
{}
func
(
nn
*
metricsNotifiee
)
ClosedStream
(
n
inet
.
Network
,
v
inet
.
Stream
)
{}
func
(
nn
*
metricsNotifiee
)
Listen
(
n
inet
.
Network
,
a
ma
.
Multiaddr
)
{}
func
(
nn
*
metricsNotifiee
)
ListenClose
(
n
inet
.
Network
,
a
ma
.
Multiaddr
)
{}
func
peersTotalGauge
(
id
peer
.
ID
)
prom
.
Gauge
{
return
peersTotal
.
With
(
prom
.
Labels
{
"peer_id"
:
id
.
Pretty
()})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment