github.com/koko1123/flow-go-1@v0.29.6/module/metrics.go (about) 1 package module 2 3 import ( 4 "time" 5 6 rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager" 7 8 "github.com/koko1123/flow-go-1/model/chainsync" 9 "github.com/koko1123/flow-go-1/model/cluster" 10 "github.com/koko1123/flow-go-1/model/flow" 11 ) 12 13 type EntriesFunc func() uint 14 15 // ResolverMetrics encapsulates the metrics collectors for dns resolver module of the networking layer. 16 type ResolverMetrics interface { 17 // DNSLookupDuration tracks the time spent to resolve a DNS address. 18 DNSLookupDuration(duration time.Duration) 19 20 // OnDNSCacheMiss tracks the total number of dns requests resolved through looking up the network. 21 OnDNSCacheMiss() 22 23 // DNSCacheResolution tracks the total number of dns requests resolved through the cache without 24 // looking up the network. 25 OnDNSCacheHit() 26 27 // OnDNSCacheInvalidated is called whenever dns cache is invalidated for an entry 28 OnDNSCacheInvalidated() 29 30 // OnDNSLookupRequestDropped tracks the number of dns lookup requests that are dropped due to a full queue 31 OnDNSLookupRequestDropped() 32 } 33 34 // NetworkSecurityMetrics metrics related to network protection. 35 type NetworkSecurityMetrics interface { 36 // OnUnauthorizedMessage tracks the number of unauthorized messages seen on the network. 37 OnUnauthorizedMessage(role, msgType, topic, offense string) 38 39 // OnRateLimitedUnicastMessage tracks the number of rate limited messages seen on the network. 40 OnRateLimitedUnicastMessage(role, msgType, topic, reason string) 41 } 42 43 // GossipSubRouterMetrics encapsulates the metrics collectors for GossipSubRouter module of the networking layer. 44 // It mostly collects the metrics related to the control message exchange between nodes over the GossipSub protocol. 45 type GossipSubRouterMetrics interface { 46 // OnIncomingRpcAcceptedFully tracks the number of RPC messages received by the node that are fully accepted. 47 // An RPC may contain any number of control messages, i.e., IHAVE, IWANT, GRAFT, PRUNE, as well as the actual messages. 48 // A fully accepted RPC means that all the control messages are accepted and all the messages are accepted. 49 OnIncomingRpcAcceptedFully() 50 51 // OnIncomingRpcAcceptedOnlyForControlMessages tracks the number of RPC messages received by the node that are accepted 52 // only for the control messages, i.e., only for the included IHAVE, IWANT, GRAFT, PRUNE. However, the actual messages 53 // included in the RPC are not accepted. 54 // This happens mostly when the validation pipeline of GossipSub is throttled, and cannot accept more actual messages for 55 // validation. 56 OnIncomingRpcAcceptedOnlyForControlMessages() 57 58 // OnIncomingRpcRejected tracks the number of RPC messages received by the node that are rejected. 59 // This happens mostly when the RPC is coming from a low-scored peer based on the peer scoring module of GossipSub. 60 OnIncomingRpcRejected() 61 62 // OnIWantReceived tracks the number of IWANT messages received by the node from other nodes over an RPC message. 63 // iWant is a control message that is sent by a node to request a message that it has seen advertised in an iHAVE message. 64 OnIWantReceived(count int) 65 66 // OnIHaveReceived tracks the number of IHAVE messages received by the node from other nodes over an RPC message. 67 // iHave is a control message that is sent by a node to another node to indicate that it has a new gossiped message. 68 OnIHaveReceived(count int) 69 70 // OnGraftReceived tracks the number of GRAFT messages received by the node from other nodes over an RPC message. 71 // GRAFT is a control message of GossipSub protocol that connects two nodes over a topic directly as gossip partners. 72 OnGraftReceived(count int) 73 74 // OnPruneReceived tracks the number of PRUNE messages received by the node from other nodes over an RPC message. 75 // PRUNE is a control message of GossipSub protocol that disconnects two nodes over a topic. 76 OnPruneReceived(count int) 77 78 // OnPublishedGossipMessagesReceived tracks the number of gossip messages received by the node from other nodes over an 79 // RPC message. 80 OnPublishedGossipMessagesReceived(count int) 81 } 82 83 type LibP2PMetrics interface { 84 GossipSubRouterMetrics 85 ResolverMetrics 86 DHTMetrics 87 rcmgr.MetricsReporter 88 LibP2PConnectionMetrics 89 } 90 91 // NetworkInboundQueueMetrics encapsulates the metrics collectors for the inbound queue of the networking layer. 92 type NetworkInboundQueueMetrics interface { 93 // MessageAdded increments the metric tracking the number of messages in the queue with the given priority 94 MessageAdded(priority int) 95 96 // MessageRemoved decrements the metric tracking the number of messages in the queue with the given priority 97 MessageRemoved(priority int) 98 99 // QueueDuration tracks the time spent by a message with the given priority in the queue 100 QueueDuration(duration time.Duration, priority int) 101 } 102 103 // NetworkCoreMetrics encapsulates the metrics collectors for the core networking layer functionality. 104 type NetworkCoreMetrics interface { 105 NetworkInboundQueueMetrics 106 // OutboundMessageSent collects metrics related to a message sent by the node. 107 OutboundMessageSent(sizeBytes int, topic string, protocol string, messageType string) 108 // InboundMessageReceived collects metrics related to a message received by the node. 109 InboundMessageReceived(sizeBytes int, topic string, protocol string, messageType string) 110 // DuplicateInboundMessagesDropped increments the metric tracking the number of duplicate messages dropped by the node. 111 DuplicateInboundMessagesDropped(topic string, protocol string, messageType string) 112 // UnicastMessageSendingStarted increments the metric tracking the number of unicast messages sent by the node. 113 UnicastMessageSendingStarted(topic string) 114 // UnicastMessageSendingCompleted decrements the metric tracking the number of unicast messages sent by the node. 115 UnicastMessageSendingCompleted(topic string) 116 // MessageProcessingStarted increments the metric tracking the number of messages being processed by the node. 117 MessageProcessingStarted(topic string) 118 // MessageProcessingFinished tracks the time spent by the node to process a message and decrements the metric tracking 119 // the number of messages being processed by the node. 120 MessageProcessingFinished(topic string, duration time.Duration) 121 } 122 123 // LibP2PConnectionMetrics encapsulates the metrics collectors for the connection manager of the libp2p node. 124 type LibP2PConnectionMetrics interface { 125 // OutboundConnections updates the metric tracking the number of outbound connections of this node 126 OutboundConnections(connectionCount uint) 127 128 // InboundConnections updates the metric tracking the number of inbound connections of this node 129 InboundConnections(connectionCount uint) 130 } 131 132 // NetworkMetrics is the blanket abstraction that encapsulates the metrics collectors for the networking layer. 133 type NetworkMetrics interface { 134 LibP2PMetrics 135 NetworkSecurityMetrics 136 NetworkCoreMetrics 137 } 138 139 type EngineMetrics interface { 140 MessageSent(engine string, message string) 141 MessageReceived(engine string, message string) 142 MessageHandled(engine string, messages string) 143 } 144 145 type ComplianceMetrics interface { 146 FinalizedHeight(height uint64) 147 CommittedEpochFinalView(view uint64) 148 SealedHeight(height uint64) 149 BlockFinalized(*flow.Block) 150 BlockSealed(*flow.Block) 151 BlockProposalDuration(duration time.Duration) 152 CurrentEpochCounter(counter uint64) 153 CurrentEpochPhase(phase flow.EpochPhase) 154 CurrentEpochFinalView(view uint64) 155 CurrentDKGPhase1FinalView(view uint64) 156 CurrentDKGPhase2FinalView(view uint64) 157 CurrentDKGPhase3FinalView(view uint64) 158 EpochEmergencyFallbackTriggered() 159 } 160 161 type CleanerMetrics interface { 162 RanGC(took time.Duration) 163 } 164 165 type CacheMetrics interface { 166 // CacheEntries report the total number of cached items 167 CacheEntries(resource string, entries uint) 168 // CacheHit report the number of times the queried item is found in the cache 169 CacheHit(resource string) 170 // CacheNotFound records the number of times the queried item was not found in either cache or database. 171 CacheNotFound(resource string) 172 // CacheMiss report the number of times the queried item is not found in the cache, but found in the database. 173 CacheMiss(resource string) 174 } 175 176 type MempoolMetrics interface { 177 MempoolEntries(resource string, entries uint) 178 Register(resource string, entriesFunc EntriesFunc) error 179 } 180 181 type HotstuffMetrics interface { 182 // HotStuffBusyDuration reports Metrics C6 HotStuff Busy Duration 183 HotStuffBusyDuration(duration time.Duration, event string) 184 185 // HotStuffIdleDuration reports Metrics C6 HotStuff Idle Duration 186 HotStuffIdleDuration(duration time.Duration) 187 188 // HotStuffWaitDuration reports Metrics C6 HotStuff Idle Duration 189 HotStuffWaitDuration(duration time.Duration, event string) 190 191 // SetCurView reports Metrics C8: Current View 192 SetCurView(view uint64) 193 194 // SetQCView reports Metrics C9: View of Newest Known QC 195 SetQCView(view uint64) 196 197 // CountSkipped reports the number of times we skipped ahead. 198 CountSkipped() 199 200 // CountTimeout reports the number of times we timed out. 201 CountTimeout() 202 203 // SetTimeout sets the current timeout duration 204 SetTimeout(duration time.Duration) 205 206 // CommitteeProcessingDuration measures the time which the HotStuff's core logic 207 // spends in the hotstuff.Committee component, i.e. the time determining consensus 208 // committee relations. 209 CommitteeProcessingDuration(duration time.Duration) 210 211 // SignerProcessingDuration measures the time which the HotStuff's core logic 212 // spends in the hotstuff.Signer component, i.e. the with crypto-related operations. 213 SignerProcessingDuration(duration time.Duration) 214 215 // ValidatorProcessingDuration measures the time which the HotStuff's core logic 216 // spends in the hotstuff.Validator component, i.e. the with verifying 217 // consensus messages. 218 ValidatorProcessingDuration(duration time.Duration) 219 220 // PayloadProductionDuration measures the time which the HotStuff's core logic 221 // spends in the module.Builder component, i.e. the with generating block payloads. 222 PayloadProductionDuration(duration time.Duration) 223 } 224 225 type CollectionMetrics interface { 226 // TransactionIngested is called when a new transaction is ingested by the 227 // node. It increments the total count of ingested transactions and starts 228 // a tx->col span for the transaction. 229 TransactionIngested(txID flow.Identifier) 230 231 // ClusterBlockProposed is called when a new collection is proposed by us or 232 // any other node in the cluster. 233 ClusterBlockProposed(block *cluster.Block) 234 235 // ClusterBlockFinalized is called when a collection is finalized. 236 ClusterBlockFinalized(block *cluster.Block) 237 } 238 239 type ConsensusMetrics interface { 240 // StartCollectionToFinalized reports Metrics C1: Collection Received by CCL→ Collection Included in Finalized Block 241 StartCollectionToFinalized(collectionID flow.Identifier) 242 243 // FinishCollectionToFinalized reports Metrics C1: Collection Received by CCL→ Collection Included in Finalized Block 244 FinishCollectionToFinalized(collectionID flow.Identifier) 245 246 // StartBlockToSeal reports Metrics C4: Block Received by CCL → Block Seal in finalized block 247 StartBlockToSeal(blockID flow.Identifier) 248 249 // FinishBlockToSeal reports Metrics C4: Block Received by CCL → Block Seal in finalized block 250 FinishBlockToSeal(blockID flow.Identifier) 251 252 // EmergencySeal increments the number of seals that were created in emergency mode 253 EmergencySeal() 254 255 // OnReceiptProcessingDuration records the number of seconds spent processing a receipt 256 OnReceiptProcessingDuration(duration time.Duration) 257 258 // OnApprovalProcessingDuration records the number of seconds spent processing an approval 259 OnApprovalProcessingDuration(duration time.Duration) 260 261 // CheckSealingDuration records absolute time for the full sealing check by the consensus match engine 262 CheckSealingDuration(duration time.Duration) 263 } 264 265 type VerificationMetrics interface { 266 // OnBlockConsumerJobDone is invoked by block consumer whenever it is notified a job is done by a worker. It 267 // sets the last processed block job index. 268 OnBlockConsumerJobDone(uint64) 269 // OnChunkConsumerJobDone is invoked by chunk consumer whenever it is notified a job is done by a worker. It 270 // sets the last processed chunk job index. 271 OnChunkConsumerJobDone(uint64) 272 // OnExecutionResultReceivedAtAssignerEngine is called whenever a new execution result arrives 273 // at Assigner engine. It increments total number of received execution results. 274 OnExecutionResultReceivedAtAssignerEngine() 275 276 // OnVerifiableChunkReceivedAtVerifierEngine increments a counter that keeps track of number of verifiable chunks received at 277 // verifier engine from fetcher engine. 278 OnVerifiableChunkReceivedAtVerifierEngine() 279 280 // OnFinalizedBlockArrivedAtAssigner sets a gauge that keeps track of number of the latest block height arrives 281 // at assigner engine. Note that it assumes blocks are coming to assigner engine in strictly increasing order of their height. 282 OnFinalizedBlockArrivedAtAssigner(height uint64) 283 284 // OnChunksAssignmentDoneAtAssigner increments a counter that keeps track of the total number of assigned chunks to 285 // the verification node. 286 OnChunksAssignmentDoneAtAssigner(chunks int) 287 288 // OnAssignedChunkProcessedAtAssigner increments a counter that keeps track of the total number of assigned chunks pushed by 289 // assigner engine to the fetcher engine. 290 OnAssignedChunkProcessedAtAssigner() 291 292 // OnAssignedChunkReceivedAtFetcher increments a counter that keeps track of number of assigned chunks arrive at fetcher engine. 293 OnAssignedChunkReceivedAtFetcher() 294 295 // OnChunkDataPackRequestSentByFetcher increments a counter that keeps track of number of chunk data pack requests that fetcher engine 296 // sends to requester engine. 297 OnChunkDataPackRequestSentByFetcher() 298 299 // OnChunkDataPackRequestReceivedByRequester increments a counter that keeps track of number of chunk data pack requests 300 // arrive at the requester engine from the fetcher engine. 301 OnChunkDataPackRequestReceivedByRequester() 302 303 // OnChunkDataPackRequestDispatchedInNetwork increments a counter that keeps track of number of chunk data pack requests that the 304 // requester engine dispatches in the network (to the execution nodes). 305 OnChunkDataPackRequestDispatchedInNetworkByRequester() 306 307 // OnChunkDataPackResponseReceivedFromNetwork increments a counter that keeps track of number of chunk data pack responses that the 308 // requester engine receives from execution nodes (through network). 309 OnChunkDataPackResponseReceivedFromNetworkByRequester() 310 311 // SetMaxChunkDataPackAttemptsForNextUnsealedHeightAtRequester is invoked when a cycle of requesting chunk data packs is done by requester engine. 312 // It updates the maximum number of attempts made by requester engine for requesting the chunk data packs of the next unsealed height. 313 // The maximum is taken over the history of all chunk data packs requested during that cycle that belong to the next unsealed height. 314 SetMaxChunkDataPackAttemptsForNextUnsealedHeightAtRequester(attempts uint64) 315 316 // OnChunkDataPackSentToFetcher increments a counter that keeps track of number of chunk data packs sent to the fetcher engine from 317 // requester engine. 318 OnChunkDataPackSentToFetcher() 319 320 // OnChunkDataPackArrivedAtFetcher increments a counter that keeps track of number of chunk data packs arrived at fetcher engine from 321 // requester engine. 322 OnChunkDataPackArrivedAtFetcher() 323 324 // OnVerifiableChunkSentToVerifier increments a counter that keeps track of number of verifiable chunks fetcher engine sent to verifier engine. 325 OnVerifiableChunkSentToVerifier() 326 327 // OnResultApprovalDispatchedInNetwork increments a counter that keeps track of number of result approvals dispatched in the network 328 // by verifier engine. 329 OnResultApprovalDispatchedInNetworkByVerifier() 330 } 331 332 // LedgerMetrics provides an interface to record Ledger Storage metrics. 333 // Ledger storage is non-linear (fork-aware) so certain metrics are averaged 334 // and computed before emitting for better visibility 335 type LedgerMetrics interface { 336 // ForestApproxMemorySize records approximate memory usage of forest (all in-memory trees) 337 ForestApproxMemorySize(bytes uint64) 338 339 // ForestNumberOfTrees current number of trees in a forest (in memory) 340 ForestNumberOfTrees(number uint64) 341 342 // LatestTrieRegCount records the number of unique register allocated (the latest created trie) 343 LatestTrieRegCount(number uint64) 344 345 // LatestTrieRegCountDiff records the difference between the number of unique register allocated of the latest created trie and parent trie 346 LatestTrieRegCountDiff(number int64) 347 348 // LatestTrieRegSize records the size of unique register allocated (the latest created trie) 349 LatestTrieRegSize(size uint64) 350 351 // LatestTrieRegSizeDiff records the difference between the size of unique register allocated of the latest created trie and parent trie 352 LatestTrieRegSizeDiff(size int64) 353 354 // LatestTrieMaxDepthTouched records the maximum depth touched of the lastest created trie 355 LatestTrieMaxDepthTouched(maxDepth uint16) 356 357 // UpdateCount increase a counter of performed updates 358 UpdateCount() 359 360 // ProofSize records a proof size 361 ProofSize(bytes uint32) 362 363 // UpdateValuesNumber accumulates number of updated values 364 UpdateValuesNumber(number uint64) 365 366 // UpdateValuesSize total size (in bytes) of updates values 367 UpdateValuesSize(byte uint64) 368 369 // UpdateDuration records absolute time for the update of a trie 370 UpdateDuration(duration time.Duration) 371 372 // UpdateDurationPerItem records update time for single value (total duration / number of updated values) 373 UpdateDurationPerItem(duration time.Duration) 374 375 // ReadValuesNumber accumulates number of read values 376 ReadValuesNumber(number uint64) 377 378 // ReadValuesSize total size (in bytes) of read values 379 ReadValuesSize(byte uint64) 380 381 // ReadDuration records absolute time for the read from a trie 382 ReadDuration(duration time.Duration) 383 384 // ReadDurationPerItem records read time for single value (total duration / number of read values) 385 ReadDurationPerItem(duration time.Duration) 386 } 387 388 type WALMetrics interface { 389 } 390 391 type RateLimitedBlockstoreMetrics interface { 392 BytesRead(int) 393 } 394 395 type BitswapMetrics interface { 396 Peers(prefix string, n int) 397 Wantlist(prefix string, n int) 398 BlobsReceived(prefix string, n uint64) 399 DataReceived(prefix string, n uint64) 400 BlobsSent(prefix string, n uint64) 401 DataSent(prefix string, n uint64) 402 DupBlobsReceived(prefix string, n uint64) 403 DupDataReceived(prefix string, n uint64) 404 MessagesReceived(prefix string, n uint64) 405 } 406 407 type ExecutionDataRequesterMetrics interface { 408 // ExecutionDataFetchStarted records an in-progress download 409 ExecutionDataFetchStarted() 410 411 // ExecutionDataFetchFinished records a completed download 412 ExecutionDataFetchFinished(duration time.Duration, success bool, height uint64) 413 414 // NotificationSent reports that ExecutionData received notifications were sent for a block height 415 NotificationSent(height uint64) 416 417 // FetchRetried reports that a download retry was processed 418 FetchRetried() 419 } 420 421 type RuntimeMetrics interface { 422 // TransactionParsed reports the time spent parsing a single transaction 423 RuntimeTransactionParsed(dur time.Duration) 424 425 // TransactionChecked reports the time spent checking a single transaction 426 RuntimeTransactionChecked(dur time.Duration) 427 428 // TransactionInterpreted reports the time spent interpreting a single transaction 429 RuntimeTransactionInterpreted(dur time.Duration) 430 431 // RuntimeSetNumberOfAccounts Sets the total number of accounts on the network 432 RuntimeSetNumberOfAccounts(count uint64) 433 } 434 435 type ProviderMetrics interface { 436 // ChunkDataPackRequestProcessed is executed every time a chunk data pack request is picked up for processing at execution node. 437 // It increases the request processed counter by one. 438 ChunkDataPackRequestProcessed() 439 } 440 441 type ExecutionDataProviderMetrics interface { 442 RootIDComputed(duration time.Duration, numberOfChunks int) 443 AddBlobsSucceeded(duration time.Duration, totalSize uint64) 444 AddBlobsFailed() 445 } 446 447 type ExecutionDataRequesterV2Metrics interface { 448 FulfilledHeight(blockHeight uint64) 449 ReceiptSkipped() 450 RequestSucceeded(blockHeight uint64, duration time.Duration, totalSize uint64, numberOfAttempts int) 451 RequestFailed(duration time.Duration, retryable bool) 452 RequestCanceled() 453 ResponseDropped() 454 } 455 456 type ExecutionDataPrunerMetrics interface { 457 Pruned(height uint64, duration time.Duration) 458 } 459 460 type AccessMetrics interface { 461 // TotalConnectionsInPool updates the number connections to collection/execution nodes stored in the pool, and the size of the pool 462 TotalConnectionsInPool(connectionCount uint, connectionPoolSize uint) 463 464 // ConnectionFromPoolReused tracks the number of times a connection to a collection/execution node is reused from the connection pool 465 ConnectionFromPoolReused() 466 467 // ConnectionAddedToPool tracks the number of times a collection/execution node is added to the connection pool 468 ConnectionAddedToPool() 469 470 // NewConnectionEstablished tracks the number of times a new grpc connection is established 471 NewConnectionEstablished() 472 473 // ConnectionFromPoolInvalidated tracks the number of times a cached grpc connection is invalidated and closed 474 ConnectionFromPoolInvalidated() 475 476 // ConnectionFromPoolUpdated tracks the number of times a cached connection is updated 477 ConnectionFromPoolUpdated() 478 479 // ConnectionFromPoolEvicted tracks the number of times a cached connection is evicted from the cache 480 ConnectionFromPoolEvicted() 481 } 482 483 type ExecutionResultStats struct { 484 ComputationUsed uint64 485 MemoryUsed uint64 486 EventCounts int 487 EventSize int 488 NumberOfRegistersTouched int 489 NumberOfBytesWrittenToRegisters int 490 NumberOfCollections int 491 NumberOfTransactions int 492 } 493 494 func (stats *ExecutionResultStats) Merge(other ExecutionResultStats) { 495 stats.ComputationUsed += other.ComputationUsed 496 stats.MemoryUsed += other.MemoryUsed 497 stats.EventCounts += other.EventCounts 498 stats.EventSize += other.EventSize 499 stats.NumberOfRegistersTouched += other.NumberOfRegistersTouched 500 stats.NumberOfBytesWrittenToRegisters += other.NumberOfBytesWrittenToRegisters 501 stats.NumberOfCollections += other.NumberOfCollections 502 stats.NumberOfTransactions += other.NumberOfTransactions 503 } 504 505 type ExecutionMetrics interface { 506 LedgerMetrics 507 RuntimeMetrics 508 ProviderMetrics 509 WALMetrics 510 511 // StartBlockReceivedToExecuted starts a span to trace the duration of a block 512 // from being received for execution to execution being finished 513 StartBlockReceivedToExecuted(blockID flow.Identifier) 514 515 // FinishBlockReceivedToExecuted finishes a span to trace the duration of a block 516 // from being received for execution to execution being finished 517 FinishBlockReceivedToExecuted(blockID flow.Identifier) 518 519 // ExecutionStorageStateCommitment reports the storage size of a state commitment in bytes 520 ExecutionStorageStateCommitment(bytes int64) 521 522 // ExecutionLastExecutedBlockHeight reports last executed block height 523 ExecutionLastExecutedBlockHeight(height uint64) 524 525 // ExecutionBlockExecuted reports the total time and computation spent on executing a block 526 ExecutionBlockExecuted(dur time.Duration, stats ExecutionResultStats) 527 528 // ExecutionBlockExecutionEffortVectorComponent reports the unweighted effort of given ComputationKind at block level 529 ExecutionBlockExecutionEffortVectorComponent(string, uint) 530 531 // ExecutionCollectionExecuted reports the total time and computation spent on executing a collection 532 ExecutionCollectionExecuted(dur time.Duration, stats ExecutionResultStats) 533 534 // ExecutionTransactionExecuted reports stats on executing a single transaction 535 ExecutionTransactionExecuted(dur time.Duration, 536 compUsed, memoryUsed, actualMemoryUsed uint64, 537 eventCounts, eventSize int, 538 failed bool) 539 540 // ExecutionChunkDataPackGenerated reports stats on chunk data pack generation 541 ExecutionChunkDataPackGenerated(proofSize, numberOfTransactions int) 542 543 // ExecutionScriptExecuted reports the time and memory spent on executing an script 544 ExecutionScriptExecuted(dur time.Duration, compUsed, memoryUsed, memoryEstimate uint64) 545 546 // ExecutionCollectionRequestSent reports when a request for a collection is sent to a collection node 547 ExecutionCollectionRequestSent() 548 549 // Unused 550 ExecutionCollectionRequestRetried() 551 552 // ExecutionSync reports when the state syncing is triggered or stopped. 553 ExecutionSync(syncing bool) 554 555 // Upload metrics 556 ExecutionBlockDataUploadStarted() 557 ExecutionBlockDataUploadFinished(dur time.Duration) 558 ExecutionComputationResultUploaded() 559 ExecutionComputationResultUploadRetried() 560 561 UpdateCollectionMaxHeight(height uint64) 562 } 563 564 type BackendScriptsMetrics interface { 565 // Record the round trip time while executing a script 566 ScriptExecuted(dur time.Duration, size int) 567 } 568 569 type TransactionMetrics interface { 570 BackendScriptsMetrics 571 572 // Record the round trip time while getting a transaction result 573 TransactionResultFetched(dur time.Duration, size int) 574 575 // TransactionReceived starts tracking of transaction execution/finalization/sealing 576 TransactionReceived(txID flow.Identifier, when time.Time) 577 578 // TransactionFinalized reports the time spent between the transaction being received and finalized. Reporting only 579 // works if the transaction was earlier added as received. 580 TransactionFinalized(txID flow.Identifier, when time.Time) 581 582 // TransactionExecuted reports the time spent between the transaction being received and executed. Reporting only 583 // works if the transaction was earlier added as received. 584 TransactionExecuted(txID flow.Identifier, when time.Time) 585 586 // TransactionExpired tracks number of expired transactions 587 TransactionExpired(txID flow.Identifier) 588 589 // TransactionSubmissionFailed should be called whenever we try to submit a transaction and it fails 590 TransactionSubmissionFailed() 591 592 // UpdateExecutionReceiptMaxHeight is called whenever we store an execution receipt from a block from a newer height 593 UpdateExecutionReceiptMaxHeight(height uint64) 594 } 595 596 type PingMetrics interface { 597 // NodeReachable tracks the round trip time in milliseconds taken to ping a node 598 // The nodeInfo provides additional information about the node such as the name of the node operator 599 NodeReachable(node *flow.Identity, nodeInfo string, rtt time.Duration) 600 601 // NodeInfo tracks the software version, sealed height and hotstuff view of a node 602 NodeInfo(node *flow.Identity, nodeInfo string, version string, sealedHeight uint64, hotstuffCurView uint64) 603 } 604 605 type HeroCacheMetrics interface { 606 // BucketAvailableSlots keeps track of number of available slots in buckets of cache. 607 BucketAvailableSlots(uint64, uint64) 608 609 // OnKeyPutAttempt is called whenever a new (key, value) pair is attempted to be put in cache. 610 // It does not reflect whether the put was successful or not. 611 // A (key, value) pair put attempt may fail if the cache is full, or the key already exists. 612 OnKeyPutAttempt(size uint32) 613 614 // OnKeyPutSuccess is called whenever a new (key, entity) pair is successfully added to the cache. 615 OnKeyPutSuccess(size uint32) 616 617 // OnKeyPutDrop is called whenever a new (key, entity) pair is dropped from the cache due to full cache. 618 OnKeyPutDrop() 619 620 // OnKeyPutDeduplicated is tracking the total number of unsuccessful writes caused by adding a duplicate key to the cache. 621 // A duplicate key is dropped by the cache when it is written to the cache. 622 // Note: in context of HeroCache, the key corresponds to the identifier of its entity. Hence, a duplicate key corresponds to 623 // a duplicate entity. 624 OnKeyPutDeduplicated() 625 626 // OnKeyRemoved is called whenever a (key, entity) pair is removed from the cache. 627 OnKeyRemoved(size uint32) 628 629 // OnKeyGetSuccess tracks total number of successful read queries. 630 // A read query is successful if the entity corresponding to its key is available in the cache. 631 // Note: in context of HeroCache, the key corresponds to the identifier of its entity. 632 OnKeyGetSuccess() 633 634 // OnKeyGetFailure tracks total number of unsuccessful read queries. 635 // A read query is unsuccessful if the entity corresponding to its key is not available in the cache. 636 // Note: in context of HeroCache, the key corresponds to the identifier of its entity. 637 OnKeyGetFailure() 638 639 // OnEntityEjectionDueToFullCapacity is called whenever adding a new (key, entity) to the cache results in ejection of another (key', entity') pair. 640 // This normally happens -- and is expected -- when the cache is full. 641 // Note: in context of HeroCache, the key corresponds to the identifier of its entity. 642 OnEntityEjectionDueToFullCapacity() 643 644 // OnEntityEjectionDueToEmergency is called whenever a bucket is found full and all of its keys are valid, i.e., 645 // each key belongs to an existing (key, entity) pair. 646 // Hence, adding a new key to that bucket will replace the oldest valid key inside that bucket. 647 // Note: in context of HeroCache, the key corresponds to the identifier of its entity. 648 OnEntityEjectionDueToEmergency() 649 } 650 651 type ChainSyncMetrics interface { 652 // record pruned blocks. requested and received times might be zero values 653 PrunedBlockById(status *chainsync.Status) 654 655 PrunedBlockByHeight(status *chainsync.Status) 656 657 // totalByHeight and totalById are the number of blocks pruned for blocks requested by height and by id 658 // storedByHeight and storedById are the number of blocks still stored by height and id 659 PrunedBlocks(totalByHeight, totalById, storedByHeight, storedById int) 660 661 RangeRequested(ran chainsync.Range) 662 663 BatchRequested(batch chainsync.Batch) 664 } 665 666 type DHTMetrics interface { 667 RoutingTablePeerAdded() 668 RoutingTablePeerRemoved() 669 }