This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #696 from yeya24/add-metrics-docs
docs: add a doc about how to add metrics
- Loading branch information
Showing
10 changed files
with
127 additions
and
63 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package util | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
const ( | ||
namespace = "dragonfly" | ||
) | ||
|
||
// NewCounter will auto-register a Counter metric to prometheus default registry and return it. | ||
func NewCounter(subsystem, name, help string, labels []string) *prometheus.CounterVec { | ||
return promauto.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: name, | ||
Help: help, | ||
}, | ||
labels, | ||
) | ||
} | ||
|
||
// NewGauge will auto-register a Gauge metric to prometheus default registry and return it. | ||
func NewGauge(subsystem, name, help string, labels []string) *prometheus.GaugeVec { | ||
return promauto.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: name, | ||
Help: help, | ||
}, | ||
labels, | ||
) | ||
} | ||
|
||
// NewSummary will auto-register a Summary metric to prometheus default registry and return it. | ||
func NewSummary(subsystem, name, help string, labels []string, objectives map[float64]float64) *prometheus.SummaryVec { | ||
return promauto.NewSummaryVec( | ||
prometheus.SummaryOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: name, | ||
Help: help, | ||
Objectives: objectives, | ||
}, | ||
labels, | ||
) | ||
} | ||
|
||
// NewHistogram will auto-register a Histogram metric to prometheus default registry and return it. | ||
func NewHistogram(subsystem, name, help string, labels []string, buckets []float64) *prometheus.HistogramVec { | ||
return promauto.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: name, | ||
Help: help, | ||
Buckets: buckets, | ||
}, | ||
labels, | ||
) | ||
} |
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
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