Skip to content

Commit

Permalink
Merge pull request #72 from libp2p/marco/record-block-resource-dir
Browse files Browse the repository at this point in the history
Record which direction the resource was blocked
  • Loading branch information
MarcoPolo authored Jul 27, 2022
2 parents 562d88f + a32c7a3 commit ba3117d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions p2p/host/resource-manager/obs/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,22 @@ func (r StatsTraceReporter) ConsumeEvent(evt rcmgr.TraceEvt) {
// Drop the connection or stream id
scopeName = strings.SplitN(scopeName, "-", 2)[0]

// If something else gets added here, make sure to update the size hint
// below when we make `tagsWithDir`.
tags := []tag.Mutator{tag.Upsert(scopeTag, scopeName), tag.Upsert(resourceTag, resource)}

if evt.DeltaIn != 0 {
stats.RecordWithTags(ctx, tags, blockedResources.M(int64(1)))
tagsWithDir := make([]tag.Mutator, 3)
tagsWithDir = append(tagsWithDir, tag.Insert(directionTag, "inbound"))
tagsWithDir = append(tagsWithDir, tags...)
stats.RecordWithTags(ctx, tagsWithDir[0:], blockedResources.M(int64(1)))
}

if evt.DeltaOut != 0 {
stats.RecordWithTags(ctx, tags, blockedResources.M(int64(1)))
tagsWithDir := make([]tag.Mutator, 3)
tagsWithDir = append(tagsWithDir, tag.Insert(directionTag, "outbound"))
tagsWithDir = append(tagsWithDir, tags...)
stats.RecordWithTags(ctx, tagsWithDir, blockedResources.M(int64(1)))
}

if evt.Delta != 0 {
Expand Down

0 comments on commit ba3117d

Please sign in to comment.