2020-02-26 02:42:34 +00:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.opencensus.io/stats"
|
|
|
|
"go.opencensus.io/stats/view"
|
|
|
|
"go.opencensus.io/tag"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Global Tags
|
|
|
|
var (
|
2020-03-02 00:26:09 +00:00
|
|
|
Version, _ = tag.NewKey("version")
|
|
|
|
Commit, _ = tag.NewKey("commit")
|
|
|
|
RPCMethod, _ = tag.NewKey("method")
|
|
|
|
PeerID, _ = tag.NewKey("peer_id")
|
2020-03-02 00:57:16 +00:00
|
|
|
FailureType, _ = tag.NewKey("failure_type")
|
2020-03-02 00:26:09 +00:00
|
|
|
MessageFrom, _ = tag.NewKey("message_from")
|
|
|
|
MessageTo, _ = tag.NewKey("message_to")
|
|
|
|
MessageNonce, _ = tag.NewKey("message_nonce")
|
2020-03-02 00:57:16 +00:00
|
|
|
ReceivedFrom, _ = tag.NewKey("received_from")
|
2020-02-26 02:42:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Measures
|
|
|
|
var (
|
2020-03-02 00:57:16 +00:00
|
|
|
LotusInfo = stats.Int64("info", "Arbitrary counter to tag lotus info to", stats.UnitDimensionless)
|
|
|
|
ChainNodeHeight = stats.Int64("chain/node_height", "Current Height of the node", stats.UnitDimensionless)
|
|
|
|
ChainNodeWorkerHeight = stats.Int64("chain/node_worker_height", "Current Height of workers on the node", stats.UnitDimensionless)
|
|
|
|
MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless)
|
|
|
|
MessageValidationFailure = stats.Int64("message/failure", "Counter for message validation failures", stats.UnitDimensionless)
|
|
|
|
MessageValidationSuccess = stats.Int64("message/success", "Counter for message validation successes", stats.UnitDimensionless)
|
|
|
|
BlockReceived = stats.Int64("block/received", "Counter for total received blocks", stats.UnitDimensionless)
|
|
|
|
BlockValidationFailure = stats.Int64("block/failure", "Counter for block validation failures", stats.UnitDimensionless)
|
|
|
|
BlockValidationSuccess = stats.Int64("block/success", "Counter for block validation successes", stats.UnitDimensionless)
|
|
|
|
PeerCount = stats.Int64("peer/count", "Current number of FIL peers", stats.UnitDimensionless)
|
|
|
|
RPCInvalidMethod = stats.Int64("rpc/invalid_method", "Total number of invalid RPC methods called", stats.UnitDimensionless)
|
|
|
|
RPCRequestError = stats.Int64("rpc/request_error", "Total number of request errors handled", stats.UnitDimensionless)
|
|
|
|
RPCResponseError = stats.Int64("rpc/response_error", "Total number of responses errors handled", stats.UnitDimensionless)
|
2020-02-26 02:42:34 +00:00
|
|
|
)
|
|
|
|
|
2020-03-05 09:47:20 +00:00
|
|
|
var (
|
|
|
|
InfoView = &view.View{
|
2020-02-26 02:42:34 +00:00
|
|
|
Name: "info",
|
|
|
|
Description: "Lotus node information",
|
|
|
|
Measure: LotusInfo,
|
|
|
|
Aggregation: view.LastValue(),
|
|
|
|
TagKeys: []tag.Key{Version, Commit},
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
ChainNodeHeightView = &view.View{
|
2020-03-02 00:26:09 +00:00
|
|
|
Measure: ChainNodeHeight,
|
2020-02-26 02:42:34 +00:00
|
|
|
Aggregation: view.LastValue(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
ChainNodeWorkerHeightView = &view.View{
|
2020-03-02 00:26:09 +00:00
|
|
|
Measure: ChainNodeWorkerHeight,
|
|
|
|
Aggregation: view.LastValue(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
BlockReceivedView = &view.View{
|
2020-03-02 00:57:16 +00:00
|
|
|
Measure: BlockReceived,
|
2020-03-02 00:26:09 +00:00
|
|
|
Aggregation: view.Count(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
BlockValidationFailureView = &view.View{
|
2020-03-02 00:57:16 +00:00
|
|
|
Measure: BlockValidationFailure,
|
|
|
|
Aggregation: view.Count(),
|
2020-03-05 09:47:20 +00:00
|
|
|
TagKeys: []tag.Key{FailureType},
|
|
|
|
}
|
|
|
|
BlockValidationSuccessView = &view.View{
|
2020-03-02 00:57:16 +00:00
|
|
|
Measure: BlockValidationSuccess,
|
|
|
|
Aggregation: view.Count(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
MessageReceivedView = &view.View{
|
2020-03-02 00:57:16 +00:00
|
|
|
Measure: MessageReceived,
|
|
|
|
Aggregation: view.Count(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
MessageValidationFailureView = &view.View{
|
2020-03-02 00:57:16 +00:00
|
|
|
Measure: MessageValidationFailure,
|
|
|
|
Aggregation: view.Count(),
|
2020-03-05 09:47:20 +00:00
|
|
|
TagKeys: []tag.Key{FailureType},
|
|
|
|
}
|
|
|
|
MessageValidationSuccessView = &view.View{
|
2020-03-02 00:57:16 +00:00
|
|
|
Measure: MessageValidationSuccess,
|
2020-03-02 00:26:09 +00:00
|
|
|
Aggregation: view.Count(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
PeerCountView = &view.View{
|
2020-03-02 00:26:09 +00:00
|
|
|
Measure: PeerCount,
|
2020-02-26 02:42:34 +00:00
|
|
|
Aggregation: view.LastValue(),
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
2020-02-26 02:42:34 +00:00
|
|
|
// All RPC related metrics should at the very least tag the RPCMethod
|
2020-03-05 09:47:20 +00:00
|
|
|
RPCInvalidMethodView = &view.View{
|
2020-02-26 02:42:34 +00:00
|
|
|
Measure: RPCInvalidMethod,
|
|
|
|
Aggregation: view.Count(),
|
|
|
|
TagKeys: []tag.Key{RPCMethod},
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
RPCRequestErrorView = &view.View{
|
2020-02-28 03:44:12 +00:00
|
|
|
Measure: RPCRequestError,
|
2020-02-26 02:42:34 +00:00
|
|
|
Aggregation: view.Count(),
|
|
|
|
TagKeys: []tag.Key{RPCMethod},
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
RPCResponseErrorView = &view.View{
|
2020-02-28 03:44:12 +00:00
|
|
|
Measure: RPCResponseError,
|
2020-02-26 02:42:34 +00:00
|
|
|
Aggregation: view.Count(),
|
|
|
|
TagKeys: []tag.Key{RPCMethod},
|
2020-03-05 09:47:20 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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,
|
2020-02-26 02:42:34 +00:00
|
|
|
}
|