Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
979ed6ab
Unverified
Commit
979ed6ab
authored
Feb 27, 2020
by
Michael Muré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
metrics: also record message/request event on error
... otherwise any kinde of error ratio is meaningless.
parent
fe2d21ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
dht_net.go
dht_net.go
+16
-7
No files found.
dht_net.go
View file @
979ed6ab
...
...
@@ -96,6 +96,8 @@ func (dht *IpfsDHT) handleNewMessage(s network.Stream) bool {
ctx
,
[]
tag
.
Mutator
{
tag
.
Upsert
(
metrics
.
KeyMessageType
,
"UNKNOWN"
)},
metrics
.
ReceivedMessageErrors
.
M
(
1
),
metrics
.
ReceivedMessages
.
M
(
1
),
metrics
.
ReceivedBytes
.
M
(
int64
(
req
.
Size
())),
)
return
false
}
...
...
@@ -107,6 +109,8 @@ func (dht *IpfsDHT) handleNewMessage(s network.Stream) bool {
ctx
,
[]
tag
.
Mutator
{
tag
.
Upsert
(
metrics
.
KeyMessageType
,
"UNKNOWN"
)},
metrics
.
ReceivedMessageErrors
.
M
(
1
),
metrics
.
ReceivedMessages
.
M
(
1
),
metrics
.
ReceivedBytes
.
M
(
int64
(
req
.
Size
())),
)
return
false
}
...
...
@@ -164,6 +168,12 @@ func (dht *IpfsDHT) handleNewMessage(s network.Stream) bool {
func
(
dht
*
IpfsDHT
)
sendRequest
(
ctx
context
.
Context
,
p
peer
.
ID
,
pmes
*
pb
.
Message
)
(
*
pb
.
Message
,
error
)
{
ctx
,
_
=
tag
.
New
(
ctx
,
metrics
.
UpsertMessageType
(
pmes
))
stats
.
Record
(
ctx
,
metrics
.
SentRequests
.
M
(
1
),
metrics
.
SentBytes
.
M
(
int64
(
pmes
.
Size
())),
)
ms
,
err
:=
dht
.
messageSenderForPeer
(
ctx
,
p
)
if
err
!=
nil
{
stats
.
Record
(
ctx
,
metrics
.
SentRequestErrors
.
M
(
1
))
...
...
@@ -183,8 +193,6 @@ func (dht *IpfsDHT) sendRequest(ctx context.Context, p peer.ID, pmes *pb.Message
stats
.
Record
(
ctx
,
metrics
.
SentRequests
.
M
(
1
),
metrics
.
SentBytes
.
M
(
int64
(
pmes
.
Size
())),
metrics
.
OutboundRequestLatency
.
M
(
float64
(
time
.
Since
(
start
))
/
float64
(
time
.
Millisecond
),
),
...
...
@@ -198,6 +206,12 @@ func (dht *IpfsDHT) sendRequest(ctx context.Context, p peer.ID, pmes *pb.Message
func
(
dht
*
IpfsDHT
)
sendMessage
(
ctx
context
.
Context
,
p
peer
.
ID
,
pmes
*
pb
.
Message
)
error
{
ctx
,
_
=
tag
.
New
(
ctx
,
metrics
.
UpsertMessageType
(
pmes
))
stats
.
Record
(
ctx
,
metrics
.
SentMessages
.
M
(
1
),
metrics
.
SentBytes
.
M
(
int64
(
pmes
.
Size
())),
)
ms
,
err
:=
dht
.
messageSenderForPeer
(
ctx
,
p
)
if
err
!=
nil
{
stats
.
Record
(
ctx
,
metrics
.
SentMessageErrors
.
M
(
1
))
...
...
@@ -209,11 +223,6 @@ func (dht *IpfsDHT) sendMessage(ctx context.Context, p peer.ID, pmes *pb.Message
return
err
}
stats
.
Record
(
ctx
,
metrics
.
SentMessages
.
M
(
1
),
metrics
.
SentBytes
.
M
(
int64
(
pmes
.
Size
())),
)
logger
.
Event
(
ctx
,
"dhtSentMessage"
,
dht
.
self
,
p
,
pmes
)
return
nil
}
...
...
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