gitee.com/zhaochuninhefei/fabric-ca-gm@v0.0.2/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 "gitee.com/zhaochuninhefei/fabric-gm/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 StatsdFormat: "%{#fqname}.%{ca_name}.%{api_name}.%{status_code}", 20 } 21 22 // APIDurationOpts define the duration opts for server APIs 23 APIDurationOpts = metrics.HistogramOpts{ 24 Namespace: "api_request", 25 Subsystem: "", 26 Name: "duration", 27 Help: "Time taken in seconds for the request to an API to be completed", 28 LabelNames: []string{"ca_name", "api_name", "status_code"}, 29 StatsdFormat: "%{#fqname}.%{ca_name}.%{api_name}.%{status_code}", 30 } 31 ) 32 33 // Metrics are the metrics tracked by server 34 type Metrics struct { 35 // APICounter keeps track of number of times an API endpoint is called 36 APICounter metrics.Counter 37 // APIDuration keeps track of time taken for request to complete for an API 38 APIDuration metrics.Histogram 39 }