github.com/hyperledger-gerrit-archive/fabric-ca@v2.0.0-alpha.0.20190916143245-4cd4192f0366+incompatible/lib/server/metrics/metrics.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package metrics
     8  
     9  import "github.com/hyperledger/fabric/common/metrics"
    10  
    11  var (
    12  	// APICounterOpts define the counter opts for server APIs
    13  	APICounterOpts = metrics.CounterOpts{
    14  		Namespace:  "api_request",
    15  		Subsystem:  "",
    16  		Name:       "count",
    17  		Help:       "Number of requests made to an API",
    18  		LabelNames: []string{"ca_name", "api_name", "status_code"},
    19  		LabelHelp: map[string]string{
    20  			"api_name":    "example api_names: affiliations/{affiliation}, affiliations, certificates, enroll, reenroll, gencrl, idemix/cri, identities, register, revoke, idemix/credential, identities/{id}. ",
    21  			"status_code": "Http status code. https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    22  		},
    23  		StatsdFormat: "%{#fqname}.%{ca_name}.%{api_name}.%{status_code}",
    24  	}
    25  
    26  	// APIDurationOpts define the duration opts for server APIs
    27  	APIDurationOpts = metrics.HistogramOpts{
    28  		Namespace:  "api_request",
    29  		Subsystem:  "",
    30  		Name:       "duration",
    31  		Help:       "Time taken in seconds for the request to an API to be completed",
    32  		LabelNames: []string{"ca_name", "api_name", "status_code"},
    33  		LabelHelp: map[string]string{
    34  			"api_name":    "example api_names: affiliations/{affiliation}, affiliations, certificates, enroll, reenroll, gencrl, idemix/cri, identities, register, revoke, idemix/credential, identities/{id}. ",
    35  			"status_code": "Http status code. https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
    36  		},
    37  		StatsdFormat: "%{#fqname}.%{ca_name}.%{api_name}.%{status_code}",
    38  	}
    39  )
    40  
    41  // Metrics are the metrics tracked by server
    42  type Metrics struct {
    43  	// APICounter keeps track of number of times an API endpoint is called
    44  	APICounter metrics.Counter
    45  	// APIDuration keeps track of time taken for request to complete for an API
    46  	APIDuration metrics.Histogram
    47  }