Skip to content

Commit

Permalink
Add sample timed summary
Browse files Browse the repository at this point in the history
  • Loading branch information
panchoh authored and iknite committed Feb 19, 2019
1 parent c3e9a18 commit e6b7dec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/apihttp/apihttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func HealthCheckHandler(w http.ResponseWriter, r *http.Request) {
timer2 := prometheus.NewTimer(prometheus.ObserverFunc(metrics.FuncDuration.Set))
defer timer2.ObserveDuration()

timer3 := prometheus.NewTimer(metrics.RequestSummary)
defer timer3.ObserveDuration()

// Do something here that takes time.
time.Sleep(time.Duration(rand.NormFloat64()*10000+50000) * time.Microsecond)

Expand Down
8 changes: 8 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ var (
},
)

RequestSummary = prometheus.NewSummary(
prometheus.SummaryOpts{
Name: "example_function_durations_seconds",
Help: "example function latency distributions.",
},
)

RequestDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Name: "example_request_duration_seconds",
Expand Down Expand Up @@ -220,6 +227,7 @@ var (
Publisher_batches_process_seconds,

FuncDuration,
RequestSummary,
RequestDuration,
}
)
Expand Down

0 comments on commit e6b7dec

Please sign in to comment.