-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continuation of #1068 Addressed some of the concerns in the reviews: - Move `PrometheusMetric` method to original type where possible - Move `writeResponse` logic to api package - Improve handling slices of Prometheus marshallable types - Disable type checking in `jape`
- Loading branch information
Showing
9 changed files
with
1,158 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package alerts | ||
|
||
import "go.sia.tech/renterd/internal/prometheus" | ||
|
||
// PrometheusMetric implements prometheus.Marshaller. | ||
func (a Alert) PrometheusMetric() (metrics []prometheus.Metric) { | ||
metrics = append(metrics, prometheus.Metric{ | ||
Name: "renterd_alert", | ||
Labels: map[string]any{ | ||
"id": a.ID, | ||
"severity": a.Severity.String(), | ||
"message": a.Message, | ||
"timestamp": a.Timestamp, | ||
}, | ||
Value: 1, | ||
}) | ||
return | ||
} | ||
|
||
// PrometheusMetric implements prometheus.Marshaller. | ||
func (a AlertsResponse) PrometheusMetric() (metrics []prometheus.Metric) { | ||
metrics = prometheus.Slice(a.Alerts).PrometheusMetric() | ||
return | ||
} |
Oops, something went wrong.