Skip to content

Commit

Permalink
feat(query): add runner_status field (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
capuche2412 authored Nov 28, 2023
1 parent f773c45 commit bb45897
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/compliance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
name: Commit
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
# pick the pr HEAD instead of the merge commit
ref: ${{ github.event.pull_request.head.sha }}

- name: Conventional commit check
uses: cocogitto/[email protected]
19 changes: 14 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
Expand All @@ -18,9 +19,10 @@ var (
)

type Task struct {
Type string
Status string
Total int
Type string
Status string
RunnerStatus string
Total int
}

type DruidTasksExporter struct {
Expand All @@ -32,7 +34,7 @@ func NewDruidTasksExporter() *DruidTasksExporter {
Tasks: prometheus.NewDesc(
"dte_druid_tasks_total",
"Total number of Druid tasks per type and status.",
[]string{"type", "status"},
[]string{"type", "status", "runner_status"},
prometheus.Labels{},
)}
}
Expand Down Expand Up @@ -77,18 +79,25 @@ func (d *DruidTasksExporter) Collect(ch chan<- prometheus.Metric) {
float64(task.Total),
task.Type,
task.Status,
task.Status,
)
}
}
func ok(w http.ResponseWriter, _ *http.Request) {
io.WriteString(w, "ok")
_, err := io.WriteString(w, "ok")
if err != nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
fmt.Println("Error writing response:", err)
return
}
}

func main() {
flag.Parse()

druid := NewDruidTasksExporter()
reg := prometheus.NewPedanticRegistry()

reg.MustRegister(druid)

http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
Expand Down

0 comments on commit bb45897

Please sign in to comment.