You've already forked imgproxy
mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-12-03 23:19:17 +02:00
Refactor tracing
This commit is contained in:
committed by
Sergey Alexandrovich
parent
08b70d8b91
commit
5ba463749c
@@ -121,16 +121,12 @@ func respondWithNotModified(ctx context.Context, reqID string, r *http.Request,
|
||||
func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
if newRelicEnabled {
|
||||
var newRelicCancel context.CancelFunc
|
||||
ctx, newRelicCancel, rw = startNewRelicTransaction(ctx, rw, r)
|
||||
defer newRelicCancel()
|
||||
}
|
||||
var newRelicCancel context.CancelFunc
|
||||
ctx, newRelicCancel, rw = startNewRelicTransaction(ctx, rw, r)
|
||||
defer newRelicCancel()
|
||||
|
||||
if prometheusEnabled {
|
||||
prometheusRequestsTotal.Inc()
|
||||
defer startPrometheusDuration(prometheusRequestDuration)()
|
||||
}
|
||||
incrementPrometheusRequestsTotal()
|
||||
defer startPrometheusDuration(prometheusRequestDuration)()
|
||||
|
||||
select {
|
||||
case processingSem <- struct{}{}:
|
||||
@@ -150,12 +146,8 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
|
||||
ctx, downloadcancel, err := downloadImageCtx(ctx)
|
||||
defer downloadcancel()
|
||||
if err != nil {
|
||||
if newRelicEnabled {
|
||||
sendErrorToNewRelic(ctx, err)
|
||||
}
|
||||
if prometheusEnabled {
|
||||
incrementPrometheusErrorsTotal("download")
|
||||
}
|
||||
sendErrorToNewRelic(ctx, err)
|
||||
incrementPrometheusErrorsTotal("download")
|
||||
|
||||
if fallbackImage == nil {
|
||||
panic(err)
|
||||
@@ -202,12 +194,8 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
|
||||
imageData, processcancel, err := processImage(ctx)
|
||||
defer processcancel()
|
||||
if err != nil {
|
||||
if newRelicEnabled {
|
||||
sendErrorToNewRelic(ctx, err)
|
||||
}
|
||||
if prometheusEnabled {
|
||||
incrementPrometheusErrorsTotal("processing")
|
||||
}
|
||||
sendErrorToNewRelic(ctx, err)
|
||||
incrementPrometheusErrorsTotal("processing")
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user