Skip to content

Commit

Permalink
Merge pull request #1328 from filecoin-project/metrics/rework-default…
Browse files Browse the repository at this point in the history
…-view

remove high cardinality tags from metrics
  • Loading branch information
magik6k authored Mar 8, 2020
2 parents 8f7f2e7 + d0c7484 commit 697ab30
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
10 changes: 0 additions & 10 deletions chain/sub/incoming.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sub

import (
"context"
"fmt"
"time"

lru "github.com/hashicorp/golang-lru"
Expand Down Expand Up @@ -112,11 +111,6 @@ func (bv *BlockValidator) flagPeer(p peer.ID) {

func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub.Message) bool {
stats.Record(ctx, metrics.BlockReceived.M(1))
ctx, _ = tag.New(
ctx,
tag.Insert(metrics.PeerID, pid.String()),
tag.Insert(metrics.ReceivedFrom, msg.ReceivedFrom.String()),
)
blk, err := types.DecodeBlockMsg(msg.GetData())
if err != nil {
log.Error("got invalid block over pubsub: ", err)
Expand Down Expand Up @@ -178,7 +172,6 @@ func NewMessageValidator(mp *messagepool.MessagePool) *MessageValidator {

func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub.Message) bool {
stats.Record(ctx, metrics.MessageReceived.M(1))
ctx, _ = tag.New(ctx, tag.Insert(metrics.PeerID, pid.String()))
m, err := types.DecodeSignedMessage(msg.Message.GetData())
if err != nil {
log.Warnf("failed to decode incoming message: %s", err)
Expand All @@ -191,9 +184,6 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs
log.Warnf("failed to add message from network to message pool (From: %s, To: %s, Nonce: %d, Value: %s): %s", m.Message.From, m.Message.To, m.Message.Nonce, types.FIL(m.Message.Value), err)
ctx, _ = tag.New(
ctx,
tag.Insert(metrics.MessageFrom, m.Message.From.String()),
tag.Insert(metrics.MessageTo, m.Message.To.String()),
tag.Insert(metrics.MessageNonce, fmt.Sprint(m.Message.Nonce)),
tag.Insert(metrics.FailureType, "add"),
)
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
Expand Down
76 changes: 46 additions & 30 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,67 +36,83 @@ var (
RPCResponseError = stats.Int64("rpc/response_error", "Total number of responses errors handled", stats.UnitDimensionless)
)

// DefaultViews is an array of Consensus views for metric gathering purposes
var DefaultViews = []*view.View{
&view.View{
var (
InfoView = &view.View{
Name: "info",
Description: "Lotus node information",
Measure: LotusInfo,
Aggregation: view.LastValue(),
TagKeys: []tag.Key{Version, Commit},
},
&view.View{
}
ChainNodeHeightView = &view.View{
Measure: ChainNodeHeight,
Aggregation: view.LastValue(),
},
&view.View{
}
ChainNodeWorkerHeightView = &view.View{
Measure: ChainNodeWorkerHeight,
Aggregation: view.LastValue(),
},
&view.View{
}
BlockReceivedView = &view.View{
Measure: BlockReceived,
Aggregation: view.Count(),
},
&view.View{
}
BlockValidationFailureView = &view.View{
Measure: BlockValidationFailure,
Aggregation: view.Count(),
TagKeys: []tag.Key{FailureType, PeerID, ReceivedFrom},
},
&view.View{
TagKeys: []tag.Key{FailureType},
}
BlockValidationSuccessView = &view.View{
Measure: BlockValidationSuccess,
Aggregation: view.Count(),
},
&view.View{
}
MessageReceivedView = &view.View{
Measure: MessageReceived,
Aggregation: view.Count(),
},
&view.View{
}
MessageValidationFailureView = &view.View{
Measure: MessageValidationFailure,
Aggregation: view.Count(),
TagKeys: []tag.Key{FailureType, MessageFrom, MessageTo, MessageNonce},
},
&view.View{
TagKeys: []tag.Key{FailureType},
}
MessageValidationSuccessView = &view.View{
Measure: MessageValidationSuccess,
Aggregation: view.Count(),
},
&view.View{
}
PeerCountView = &view.View{
Measure: PeerCount,
Aggregation: view.LastValue(),
},
}
// All RPC related metrics should at the very least tag the RPCMethod
&view.View{
RPCInvalidMethodView = &view.View{
Measure: RPCInvalidMethod,
Aggregation: view.Count(),
TagKeys: []tag.Key{RPCMethod},
},
&view.View{
}
RPCRequestErrorView = &view.View{
Measure: RPCRequestError,
Aggregation: view.Count(),
TagKeys: []tag.Key{RPCMethod},
},
&view.View{
}
RPCResponseErrorView = &view.View{
Measure: RPCResponseError,
Aggregation: view.Count(),
TagKeys: []tag.Key{RPCMethod},
},
}
)

// DefaultViews is an array of OpenCensus views for metric gathering purposes
var DefaultViews = []*view.View{
InfoView,
ChainNodeHeightView,
ChainNodeWorkerHeightView,
BlockReceivedView,
BlockValidationFailureView,
BlockValidationSuccessView,
MessageReceivedView,
MessageValidationFailureView,
MessageValidationSuccessView,
PeerCountView,
RPCInvalidMethodView,
RPCRequestErrorView,
RPCResponseErrorView,
}

0 comments on commit 697ab30

Please sign in to comment.