github.com/ewagmig/fabric@v2.1.1+incompatible/common/deliver/metrics.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package deliver
     8  
     9  import (
    10  	"github.com/hyperledger/fabric/common/metrics"
    11  )
    12  
    13  var (
    14  	streamsOpened = metrics.CounterOpts{
    15  		Namespace: "deliver",
    16  		Name:      "streams_opened",
    17  		Help:      "The number of GRPC streams that have been opened for the deliver service.",
    18  	}
    19  	streamsClosed = metrics.CounterOpts{
    20  		Namespace: "deliver",
    21  		Name:      "streams_closed",
    22  		Help:      "The number of GRPC streams that have been closed for the deliver service.",
    23  	}
    24  
    25  	requestsReceived = metrics.CounterOpts{
    26  		Namespace:    "deliver",
    27  		Name:         "requests_received",
    28  		Help:         "The number of deliver requests that have been received.",
    29  		LabelNames:   []string{"channel", "filtered", "data_type"},
    30  		StatsdFormat: "%{#fqname}.%{channel}.%{filtered}.%{data_type}",
    31  	}
    32  	requestsCompleted = metrics.CounterOpts{
    33  		Namespace:    "deliver",
    34  		Name:         "requests_completed",
    35  		Help:         "The number of deliver requests that have been completed.",
    36  		LabelNames:   []string{"channel", "filtered", "data_type", "success"},
    37  		StatsdFormat: "%{#fqname}.%{channel}.%{filtered}.%{data_type}.%{success}",
    38  	}
    39  
    40  	blocksSent = metrics.CounterOpts{
    41  		Namespace:    "deliver",
    42  		Name:         "blocks_sent",
    43  		Help:         "The number of blocks sent by the deliver service.",
    44  		LabelNames:   []string{"channel", "filtered", "data_type"},
    45  		StatsdFormat: "%{#fqname}.%{channel}.%{filtered}.%{data_type}",
    46  	}
    47  )
    48  
    49  type Metrics struct {
    50  	StreamsOpened     metrics.Counter
    51  	StreamsClosed     metrics.Counter
    52  	RequestsReceived  metrics.Counter
    53  	RequestsCompleted metrics.Counter
    54  	BlocksSent        metrics.Counter
    55  }
    56  
    57  func NewMetrics(p metrics.Provider) *Metrics {
    58  	return &Metrics{
    59  		StreamsOpened:     p.NewCounter(streamsOpened),
    60  		StreamsClosed:     p.NewCounter(streamsClosed),
    61  		RequestsReceived:  p.NewCounter(requestsReceived),
    62  		RequestsCompleted: p.NewCounter(requestsCompleted),
    63  		BlocksSent:        p.NewCounter(blocksSent),
    64  	}
    65  }