diff --git a/.github/workflows/compliance.yaml b/.github/workflows/compliance.yaml index e605294..0d377a9 100644 --- a/.github/workflows/compliance.yaml +++ b/.github/workflows/compliance.yaml @@ -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/cocogitto-action@v3.5 \ No newline at end of file diff --git a/main.go b/main.go index c80ef57..29e752a 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "flag" + "fmt" "io" "log" "net/http" @@ -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 { @@ -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{}, )} } @@ -77,11 +79,17 @@ 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() { @@ -89,6 +97,7 @@ func main() { druid := NewDruidTasksExporter() reg := prometheus.NewPedanticRegistry() + reg.MustRegister(druid) http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))