github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/broadcast/metrics.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package broadcast 8 9 import "github.com/hyperledger/fabric/common/metrics" 10 11 var ( 12 validateDuration = metrics.HistogramOpts{ 13 Namespace: "broadcast", 14 Name: "validate_duration", 15 Help: "The time to validate a transaction in seconds.", 16 LabelNames: []string{"channel", "type", "status"}, 17 StatsdFormat: "%{#fqname}.%{channel}.%{type}.%{status}", 18 } 19 enqueueDuration = metrics.HistogramOpts{ 20 Namespace: "broadcast", 21 Name: "enqueue_duration", 22 Help: "The time to enqueue a transaction in seconds.", 23 LabelNames: []string{"channel", "type", "status"}, 24 StatsdFormat: "%{#fqname}.%{channel}.%{type}.%{status}", 25 } 26 processedCount = metrics.CounterOpts{ 27 Namespace: "broadcast", 28 Name: "processed_count", 29 Help: "The number of transactions processed.", 30 LabelNames: []string{"channel", "type", "status"}, 31 StatsdFormat: "%{#fqname}.%{channel}.%{type}.%{status}", 32 } 33 ) 34 35 type Metrics struct { 36 ValidateDuration metrics.Histogram 37 EnqueueDuration metrics.Histogram 38 ProcessedCount metrics.Counter 39 } 40 41 func NewMetrics(p metrics.Provider) *Metrics { 42 return &Metrics{ 43 ValidateDuration: p.NewHistogram(validateDuration), 44 EnqueueDuration: p.NewHistogram(enqueueDuration), 45 ProcessedCount: p.NewCounter(processedCount), 46 } 47 }