mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2025-01-27 12:50:07 +08:00
Add size hint to slice to hopefully have the tag slice allocated on the stack
This commit is contained in:
parent
7dda49c55d
commit
3ecce6cc34
12
obs/stats.go
12
obs/stats.go
@ -317,15 +317,21 @@ 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 {
|
||||
tagsWithDir := append([]tag.Mutator{tag.Insert(directionTag, "inbound")}, tags...)
|
||||
stats.RecordWithTags(ctx, tagsWithDir, 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 {
|
||||
tagsWithDir := append([]tag.Mutator{tag.Insert(directionTag, "outbound")}, tags...)
|
||||
tagsWithDir := make([]tag.Mutator, 3)
|
||||
tagsWithDir = append(tagsWithDir, tag.Insert(directionTag, "outbound"))
|
||||
tagsWithDir = append(tagsWithDir, tags...)
|
||||
stats.RecordWithTags(ctx, tagsWithDir, blockedResources.M(int64(1)))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user