This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
generated from mrz1836/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BUX-567): prometheus instead of plain interfaces
- Loading branch information
1 parent
0c9e6b7
commit 263fc95
Showing
6 changed files
with
53 additions
and
60 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,10 @@ | ||
package metrics | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
// Collector is an interface that is used to register metrics | ||
type Collector interface { | ||
RegisterGauge(name string) GaugeInterface | ||
RegisterGaugeVec(name string, labels ...string) GaugeVecInterface | ||
RegisterHistogramVec(name string, labels ...string) HistogramVecInterface | ||
} | ||
|
||
type GaugeVecInterface interface { | ||
WithLabelValues(lvs ...string) GaugeInterface | ||
} | ||
|
||
// GaugeInterface is an interface that is used to track gauges of values | ||
type GaugeInterface interface { | ||
Set(value float64) | ||
} | ||
|
||
// HistogramVecInterface is an interface that is used to register histograms with labels | ||
type HistogramVecInterface interface { | ||
WithLabelValues(lvs ...string) HistogramInterface | ||
} | ||
|
||
// HistogramInterface is an interface that is used to track histograms of values | ||
type HistogramInterface interface { | ||
Observe(value float64) | ||
RegisterGauge(name string) prometheus.Gauge | ||
RegisterGaugeVec(name string, labels ...string) *prometheus.GaugeVec | ||
RegisterHistogramVec(name string, labels ...string) *prometheus.HistogramVec | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
package metrics | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
// Stats is a struct that contains all the gauges that are used to track the calculated stats of the application | ||
type Stats struct { | ||
XPub GaugeInterface | ||
Utxo GaugeInterface | ||
TransactionIn GaugeInterface | ||
TransactionOut GaugeInterface | ||
Paymail GaugeInterface | ||
Destination GaugeInterface | ||
AccessKey GaugeInterface | ||
XPub prometheus.Gauge | ||
Utxo prometheus.Gauge | ||
Paymail prometheus.Gauge | ||
Destination prometheus.Gauge | ||
AccessKey prometheus.Gauge | ||
} | ||
|
||
func registerStats(collector Collector) Stats { | ||
return Stats{ | ||
XPub: collector.RegisterGauge(xpubGaugeName), | ||
Utxo: collector.RegisterGauge(utxoGaugeName), | ||
TransactionIn: collector.RegisterGauge(transactionInGaugeName), | ||
TransactionOut: collector.RegisterGauge(transactionOutGaugeName), | ||
Paymail: collector.RegisterGauge(paymailGaugeName), | ||
Destination: collector.RegisterGauge(destinationGaugeName), | ||
AccessKey: collector.RegisterGauge(accessKeyGaugeName), | ||
XPub: collector.RegisterGauge(xpubGaugeName), | ||
Utxo: collector.RegisterGauge(utxoGaugeName), | ||
Paymail: collector.RegisterGauge(paymailGaugeName), | ||
Destination: collector.RegisterGauge(destinationGaugeName), | ||
AccessKey: collector.RegisterGauge(accessKeyGaugeName), | ||
} | ||
} |