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

View file

@ -28,6 +28,7 @@ import (
"github.com/disintegration/imaging"
"github.com/muesli/smartcrop"
"github.com/muesli/smartcrop/nfnt"
"github.com/prometheus/client_golang/prometheus"
"github.com/rwcarlsen/goexif/exif"
"golang.org/x/image/bmp" // register bmp format
"golang.org/x/image/tiff" // register tiff format
@ -274,6 +275,9 @@ func exifOrientation(r io.Reader) (opt Options) {
// transformImage modifies the image m based on the transformations specified
// in opt.
func transformImage(m image.Image, opt Options) image.Image {
timer := prometheus.NewTimer(imageTransformationSummary)
defer timer.ObserveDuration()
// Parse crop and resize parameters before applying any transforms.
// This is to ensure that any percentage-based values are based off the
// size of the original image.