|
| 1 | +package metrics |
| 2 | + |
| 3 | +import ( |
| 4 | + "go.opencensus.io/stats" |
| 5 | + "go.opencensus.io/stats/view" |
| 6 | + "go.opencensus.io/tag" |
| 7 | +) |
| 8 | + |
| 9 | +// Global Tags |
| 10 | +var ( |
| 11 | + Version, _ = tag.NewKey("version") |
| 12 | + Commit, _ = tag.NewKey("commit") |
| 13 | + RPCMethod, _ = tag.NewKey("method") |
| 14 | + PeerID, _ = tag.NewKey("peer_id") |
| 15 | + FailureType, _ = tag.NewKey("failure_type") |
| 16 | + MessageFrom, _ = tag.NewKey("message_from") |
| 17 | + MessageTo, _ = tag.NewKey("message_to") |
| 18 | + MessageNonce, _ = tag.NewKey("message_nonce") |
| 19 | + ReceivedFrom, _ = tag.NewKey("received_from") |
| 20 | +) |
| 21 | + |
| 22 | +// Measures |
| 23 | +var ( |
| 24 | + LotusInfo = stats.Int64("info", "Arbitrary counter to tag lotus info to", stats.UnitDimensionless) |
| 25 | + ChainNodeHeight = stats.Int64("chain/node_height", "Current Height of the node", stats.UnitDimensionless) |
| 26 | + ChainNodeWorkerHeight = stats.Int64("chain/node_worker_height", "Current Height of workers on the node", stats.UnitDimensionless) |
| 27 | + MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless) |
| 28 | + MessageValidationFailure = stats.Int64("message/failure", "Counter for message validation failures", stats.UnitDimensionless) |
| 29 | + MessageValidationSuccess = stats.Int64("message/success", "Counter for message validation successes", stats.UnitDimensionless) |
| 30 | + BlockReceived = stats.Int64("block/received", "Counter for total received blocks", stats.UnitDimensionless) |
| 31 | + BlockValidationFailure = stats.Int64("block/failure", "Counter for block validation failures", stats.UnitDimensionless) |
| 32 | + BlockValidationSuccess = stats.Int64("block/success", "Counter for block validation successes", stats.UnitDimensionless) |
| 33 | + PeerCount = stats.Int64("peer/count", "Current number of FIL peers", stats.UnitDimensionless) |
| 34 | + RPCInvalidMethod = stats.Int64("rpc/invalid_method", "Total number of invalid RPC methods called", stats.UnitDimensionless) |
| 35 | + RPCRequestError = stats.Int64("rpc/request_error", "Total number of request errors handled", stats.UnitDimensionless) |
| 36 | + RPCResponseError = stats.Int64("rpc/response_error", "Total number of responses errors handled", stats.UnitDimensionless) |
| 37 | +) |
| 38 | + |
| 39 | +// DefaultViews is an array of Consensus views for metric gathering purposes |
| 40 | +var DefaultViews = []*view.View{ |
| 41 | + &view.View{ |
| 42 | + Name: "info", |
| 43 | + Description: "Lotus node information", |
| 44 | + Measure: LotusInfo, |
| 45 | + Aggregation: view.LastValue(), |
| 46 | + TagKeys: []tag.Key{Version, Commit}, |
| 47 | + }, |
| 48 | + &view.View{ |
| 49 | + Measure: ChainNodeHeight, |
| 50 | + Aggregation: view.LastValue(), |
| 51 | + }, |
| 52 | + &view.View{ |
| 53 | + Measure: ChainNodeWorkerHeight, |
| 54 | + Aggregation: view.LastValue(), |
| 55 | + }, |
| 56 | + &view.View{ |
| 57 | + Measure: BlockReceived, |
| 58 | + Aggregation: view.Count(), |
| 59 | + }, |
| 60 | + &view.View{ |
| 61 | + Measure: BlockValidationFailure, |
| 62 | + Aggregation: view.Count(), |
| 63 | + TagKeys: []tag.Key{FailureType, PeerID, ReceivedFrom}, |
| 64 | + }, |
| 65 | + &view.View{ |
| 66 | + Measure: BlockValidationSuccess, |
| 67 | + Aggregation: view.Count(), |
| 68 | + }, |
| 69 | + &view.View{ |
| 70 | + Measure: MessageReceived, |
| 71 | + Aggregation: view.Count(), |
| 72 | + }, |
| 73 | + &view.View{ |
| 74 | + Measure: MessageValidationFailure, |
| 75 | + Aggregation: view.Count(), |
| 76 | + TagKeys: []tag.Key{FailureType, MessageFrom, MessageTo, MessageNonce}, |
| 77 | + }, |
| 78 | + &view.View{ |
| 79 | + Measure: MessageValidationSuccess, |
| 80 | + Aggregation: view.Count(), |
| 81 | + }, |
| 82 | + &view.View{ |
| 83 | + Measure: PeerCount, |
| 84 | + Aggregation: view.LastValue(), |
| 85 | + }, |
| 86 | + // All RPC related metrics should at the very least tag the RPCMethod |
| 87 | + &view.View{ |
| 88 | + Measure: RPCInvalidMethod, |
| 89 | + Aggregation: view.Count(), |
| 90 | + TagKeys: []tag.Key{RPCMethod}, |
| 91 | + }, |
| 92 | + &view.View{ |
| 93 | + Measure: RPCRequestError, |
| 94 | + Aggregation: view.Count(), |
| 95 | + TagKeys: []tag.Key{RPCMethod}, |
| 96 | + }, |
| 97 | + &view.View{ |
| 98 | + Measure: RPCResponseError, |
| 99 | + Aggregation: view.Count(), |
| 100 | + TagKeys: []tag.Key{RPCMethod}, |
| 101 | + }, |
| 102 | +} |
0 commit comments