github.com/fnagchunpeng/fabric@v2.1.1+incompatible/core/endorser/metrics.go (about) 1 /* 2 Copyright State Street Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package endorser 8 9 import "github.com/hyperledger/fabric/common/metrics" 10 11 var ( 12 proposalDurationHistogramOpts = metrics.HistogramOpts{ 13 Namespace: "endorser", 14 Name: "proposal_duration", 15 Help: "The time to complete a proposal.", 16 LabelNames: []string{"channel", "chaincode", "success"}, 17 StatsdFormat: "%{#fqname}.%{channel}.%{chaincode}.%{success}", 18 } 19 20 receivedProposalsCounterOpts = metrics.CounterOpts{ 21 Namespace: "endorser", 22 Name: "proposals_received", 23 Help: "The number of proposals received.", 24 } 25 26 successfulProposalsCounterOpts = metrics.CounterOpts{ 27 Namespace: "endorser", 28 Name: "successful_proposals", 29 Help: "The number of successful proposals.", 30 } 31 32 proposalValidationFailureCounterOpts = metrics.CounterOpts{ 33 Namespace: "endorser", 34 Name: "proposal_validation_failures", 35 Help: "The number of proposals that have failed initial validation.", 36 } 37 38 proposalChannelACLFailureOpts = metrics.CounterOpts{ 39 Namespace: "endorser", 40 Name: "proposal_acl_failures", 41 Help: "The number of proposals that failed ACL checks.", 42 LabelNames: []string{"channel", "chaincode"}, 43 StatsdFormat: "%{#fqname}.%{channel}.%{chaincode}", 44 } 45 46 initFailureCounterOpts = metrics.CounterOpts{ 47 Namespace: "endorser", 48 Name: "chaincode_instantiation_failures", 49 Help: "The number of chaincode instantiations or upgrade that have failed.", 50 LabelNames: []string{"channel", "chaincode"}, 51 StatsdFormat: "%{#fqname}.%{channel}.%{chaincode}", 52 } 53 54 endorsementFailureCounterOpts = metrics.CounterOpts{ 55 Namespace: "endorser", 56 Name: "endorsement_failures", 57 Help: "The number of failed endorsements.", 58 LabelNames: []string{"channel", "chaincode", "chaincodeerror"}, 59 StatsdFormat: "%{#fqname}.%{channel}.%{chaincode}.%{chaincodeerror}", 60 } 61 62 duplicateTxsFailureCounterOpts = metrics.CounterOpts{ 63 Namespace: "endorser", 64 Name: "duplicate_transaction_failures", 65 Help: "The number of failed proposals due to duplicate transaction ID.", 66 LabelNames: []string{"channel", "chaincode"}, 67 StatsdFormat: "%{#fqname}.%{channel}.%{chaincode}", 68 } 69 70 simulationFailureCounterOpts = metrics.CounterOpts{ 71 Namespace: "endorser", 72 Name: "proposal_simulation_failures", 73 Help: "The number of failed proposal simulations", 74 LabelNames: []string{"channel", "chaincode"}, 75 StatsdFormat: "%{#fqname}.%{channel}.%{chaincode}", 76 } 77 ) 78 79 type Metrics struct { 80 ProposalDuration metrics.Histogram 81 ProposalsReceived metrics.Counter 82 SuccessfulProposals metrics.Counter 83 ProposalValidationFailed metrics.Counter 84 ProposalACLCheckFailed metrics.Counter 85 InitFailed metrics.Counter 86 EndorsementsFailed metrics.Counter 87 DuplicateTxsFailure metrics.Counter 88 SimulationFailure metrics.Counter 89 } 90 91 func NewMetrics(p metrics.Provider) *Metrics { 92 return &Metrics{ 93 ProposalDuration: p.NewHistogram(proposalDurationHistogramOpts), 94 ProposalsReceived: p.NewCounter(receivedProposalsCounterOpts), 95 SuccessfulProposals: p.NewCounter(successfulProposalsCounterOpts), 96 ProposalValidationFailed: p.NewCounter(proposalValidationFailureCounterOpts), 97 ProposalACLCheckFailed: p.NewCounter(proposalChannelACLFailureOpts), 98 InitFailed: p.NewCounter(initFailureCounterOpts), 99 EndorsementsFailed: p.NewCounter(endorsementFailureCounterOpts), 100 DuplicateTxsFailure: p.NewCounter(duplicateTxsFailureCounterOpts), 101 SimulationFailure: p.NewCounter(simulationFailureCounterOpts), 102 } 103 }