mirror of
https://github.com/safing/portbase
synced 2025-09-04 03:29:59 +00:00
Add internal ID to metric
This commit is contained in:
parent
8d792bdacc
commit
a34de1ce8e
2 changed files with 8 additions and 0 deletions
|
@ -43,6 +43,10 @@ type Options struct {
|
||||||
// Name defines an optional human readable name for the metric.
|
// Name defines an optional human readable name for the metric.
|
||||||
Name string
|
Name string
|
||||||
|
|
||||||
|
// InternalID specifies an alternative internal ID that will be used when
|
||||||
|
// exposing the metric via the API in a structured format.
|
||||||
|
InternalID string
|
||||||
|
|
||||||
// AlertLimit defines an upper limit that triggers an alert.
|
// AlertLimit defines an upper limit that triggers an alert.
|
||||||
AlertLimit float64
|
AlertLimit float64
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,10 @@ func register(m Metric) error {
|
||||||
if m.LabeledID() == registeredMetric.LabeledID() {
|
if m.LabeledID() == registeredMetric.LabeledID() {
|
||||||
return ErrAlreadyRegistered
|
return ErrAlreadyRegistered
|
||||||
}
|
}
|
||||||
|
if m.Opts().InternalID != "" &&
|
||||||
|
m.Opts().InternalID == registeredMetric.Opts().InternalID {
|
||||||
|
return fmt.Errorf("%w with this internal ID", ErrAlreadyRegistered)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new metric to registry and sort it.
|
// Add new metric to registry and sort it.
|
||||||
|
|
Loading…
Add table
Reference in a new issue