-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add meter with fabric and go version
FAB-13190 #done Change-Id: I038119a3f5e7c70164093788c4186ad6f50aa625 Signed-off-by: Will Lahti <wtlahti@us.ibm.com> Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com> (cherry picked from commit 969faf9)
- Loading branch information
Showing
5 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters