Skip to content

Commit

Permalink
Collect ProlongedObstructionDurationSeconds and ProlongedObstructionI…
Browse files Browse the repository at this point in the history
…ntervalSeconds
  • Loading branch information
dwillcocks committed Jul 26, 2021
1 parent 75c99a7 commit 1e63677
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions internal/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ var (
"Unknown",
nil, nil,
)
dishProlongedObstructionDurationSeconds = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "dish", "prolonged_obstruction_duration_seconds"),
"Average in seconds of prolonged obstructions",
nil, nil,
)
dishProlongedObstructionIntervalSeconds = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "dish", "prolonged_obstruction_interval_seconds"),
"Average prolonged obstruction interval in seconds",
nil, nil,
)
dishWedgeFractionObstructionRatio = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "dish", "wedge_fraction_obstruction_ratio"),
"Percentage of obstruction per wedge section",
Expand Down Expand Up @@ -241,6 +251,8 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
ch <- dishFractionObstructionRatio
ch <- dishLast24hObstructedSeconds
ch <- dishValidSeconds
ch <- dishProlongedObstructionDurationSeconds
ch <- dishProlongedObstructionIntervalSeconds
ch <- dishWedgeFractionObstructionRatio
ch <- dishWedgeAbsFractionObstructionRatio

Expand All @@ -263,14 +275,12 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
ok = ok && e.collectDishObstructions(ch)
ok = ok && e.collectDishAlerts(ch)

dishDuration := time.Since(start).Seconds()

if ok {
ch <- prometheus.MustNewConstMetric(
dishUp, prometheus.GaugeValue, 1.0,
)
ch <- prometheus.MustNewConstMetric(
dishScrapeDurationSeconds, prometheus.GaugeValue, dishDuration,
dishScrapeDurationSeconds, prometheus.GaugeValue, time.Since(start).Seconds(),
)
} else {
ch <- prometheus.MustNewConstMetric(
Expand All @@ -290,7 +300,7 @@ func (e *Exporter) collectDishContext(ch chan<- prometheus.Metric) bool {
if err != nil {
st, ok := status.FromError(err)
if ok && st.Code() != 7 {
log.Errorf("failed to collect context from dish: %s", err.Error())
log.Errorf("failed to collect dish context: %s", err.Error())
return false
}
}
Expand Down Expand Up @@ -416,6 +426,14 @@ func (e *Exporter) collectDishObstructions(ch chan<- prometheus.Metric) bool {
dishValidSeconds, prometheus.GaugeValue, float64(obstructions.GetValidS()),
)

ch <- prometheus.MustNewConstMetric(
dishProlongedObstructionDurationSeconds, prometheus.GaugeValue, float64(obstructions.GetAvgProlongedObstructionDurationS()),
)

ch <- prometheus.MustNewConstMetric(
dishProlongedObstructionIntervalSeconds, prometheus.GaugeValue, float64(obstructions.GetAvgProlongedObstructionIntervalS()),
)

for i, v := range obstructions.GetWedgeFractionObstructed() {
ch <- prometheus.MustNewConstMetric(
dishWedgeFractionObstructionRatio, prometheus.GaugeValue, float64(v),
Expand Down

0 comments on commit 1e63677

Please sign in to comment.