forked from tw-bc-group/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
41 lines (33 loc) · 839 Bytes
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package operations
import (
"sync"
"github.com/hyperledger/fabric/common/metrics"
"github.com/hyperledger/fabric/common/metrics/prometheus"
)
var (
fabricVersion = metrics.GaugeOpts{
Name: "fabric_version",
Help: "The active version of Fabric.",
LabelNames: []string{"version"},
StatsdFormat: "%{#fqname}.%{version}",
}
gaugeLock sync.Mutex
promVersionGauge metrics.Gauge
)
func versionGauge(provider metrics.Provider) metrics.Gauge {
switch provider.(type) {
case *prometheus.Provider:
gaugeLock.Lock()
defer gaugeLock.Unlock()
if promVersionGauge == nil {
promVersionGauge = provider.NewGauge(fabricVersion)
}
return promVersionGauge
default:
return provider.NewGauge(fabricVersion)
}
}