Bladeren bron

Set source image's shema+hostname to imgproxy.source_image_origin of the metric. (#1432)

* Set target hostname to peer.service of the metric.

* Use URL origin for metric.

* Use short notation.

* Change err variable name to avoid shadowing lint.
Tatsuki Sugiura 2 maanden geleden
bovenliggende
commit
5426260fa7
1 gewijzigde bestanden met toevoegingen van 5 en 0 verwijderingen
  1. 5 0
      processing_handler.go

+ 5 - 0
processing_handler.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"fmt"
 	"net/http"
+	"net/url"
 	"slices"
 	"strconv"
 	"strings"
@@ -251,6 +252,10 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
 	metrics.SetMetadata(ctx, "imgproxy.source_image_url", imageURL)
 	metrics.SetMetadata(ctx, "imgproxy.processing_options", po)
 
+	if u, ue := url.Parse(imageURL); ue == nil {
+		metrics.SetMetadata(ctx, "imgproxy.source_image_origin", u.Scheme+"://"+u.Host)
+	}
+
 	err = security.VerifySourceURL(imageURL)
 	checkErr(ctx, "security", err)