add basic prometheus support

Fixes #121
This commit is contained in:
Ben Haan 2017-11-10 16:07:07 -06:00 committed by Will Norris
parent 2eb6dfcd05
commit 8484518c93
6 changed files with 114 additions and 7 deletions

33
metrics.go Normal file
View file

@ -0,0 +1,33 @@
package imageproxy
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
requestServedFromCacheCount = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "requests_served_from_cache",
Help: "Number of requests served from cache.",
})
imageTransformationSummary = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "image_transformation_seconds",
Help: "Time taken for image transformations in seconds.",
})
remoteImageFetchErrors = prometheus.NewCounter(prometheus.CounterOpts{
Name: "remote_image_fetch_errors",
Help: "Total image fetch failures",
})
httpRequestsResponseTime = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "http",
Name: "response_time_seconds",
Help: "Request response times",
})
)
func init() {
prometheus.MustRegister(imageTransformationSummary)
prometheus.MustRegister(requestServedFromCacheCount)
prometheus.MustRegister(remoteImageFetchErrors)
prometheus.MustRegister(httpRequestsResponseTime)
}