Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
expose aleph_request_duration
Browse files Browse the repository at this point in the history
This Closes #2
  • Loading branch information
Christoph Klünter committed Feb 3, 2020
1 parent 4e7593f commit 1bedc38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/observe/aleph.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/parnurzeal/gorequest"
"github.com/prometheus/client_golang/prometheus"
)

type AlephStage struct {
Expand Down Expand Up @@ -41,6 +42,8 @@ type AlephStatus struct {
}

func GetAlephStatus(host string, token string, skipTLS bool) ([]error, string) {
timer:= prometheus.NewTimer(requestDurationMetric)
defer timer.ObserveDuration()
request := gorequest.New()
_, body, err := request.Get(host).
Set("Authorization", "ApiKey "+token).
Expand Down
5 changes: 5 additions & 0 deletions pkg/observe/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var (
"hostname",
},
)
requestDurationMetric = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "aleph_http_request_duration_seconds",
Help: "Histogram for the runtime of the request to the aleph api",
Buckets: prometheus.LinearBuckets(0.01,0.01,10),
})
)

// RegisterPrometheus adds the prometheus handler to the mux router
Expand Down

0 comments on commit 1bedc38

Please sign in to comment.