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

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package db
     8  
     9  import "github.com/hyperledger/fabric/common/metrics"
    10  
    11  var (
    12  	// APICounterOpts define the counter opts for database APIs
    13  	APICounterOpts = metrics.CounterOpts{
    14  		Namespace:  "db_api_request",
    15  		Subsystem:  "",
    16  		Name:       "count",
    17  		Help:       "Number of requests made to a database API",
    18  		LabelNames: []string{"ca_name", "func_name", "dbapi_name"},
    19  		LabelHelp: map[string]string{
    20  			"dbapi_name":  "example dbapi_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}.%{func_name}.%{dbapi_name}",
    24  	}
    25  
    26  	// APIDurationOpts define the duration opts for database APIs
    27  	APIDurationOpts = metrics.HistogramOpts{
    28  		Namespace:  "db_api_request",
    29  		Subsystem:  "",
    30  		Name:       "duration",
    31  		Help:       "Time taken in seconds for the request to a database API to be completed",
    32  		LabelNames: []string{"ca_name", "func_name", "dbapi_name"},
    33  		LabelHelp: map[string]string{
    34  			"dbapi_name":  "example dbapi_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}.%{func_name}.%{dbapi_name}",
    38  	}
    39  )
    40  
    41  // Metrics is the set of meters for the database
    42  type Metrics struct {
    43  	// APICounter keeps track of number of times a database API is called
    44  	APICounter metrics.Counter
    45  	// APIDuration keeps track of time taken for request to complete to a database API
    46  	APIDuration metrics.Histogram
    47  }