summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-09-17 17:23:58 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-09-17 17:23:58 -0600
commitc82c231ba7ec7c400e4d48ab943f57a6b29a2a2a (patch)
treef8d7298fd90059ebe694078a5a7d4251e0d953f9
parent3ee663dee195e5f8ead7879b31131f46cd0fba13 (diff)
caddyhttp: Remove server name from metrics
For some reason this breaks automatic HTTP->HTTPS redirects. I am not sure why yet, but as a hotfix remove this until we understand it better.
-rw-r--r--modules/caddyhttp/app.go2
-rw-r--r--modules/caddyhttp/metrics.go4
-rw-r--r--modules/caddyhttp/metrics_test.go15
3 files changed, 0 insertions, 21 deletions
diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go
index c8bbc95..375ca4d 100644
--- a/modules/caddyhttp/app.go
+++ b/modules/caddyhttp/app.go
@@ -226,8 +226,6 @@ func (app *App) Provision(ctx caddy.Context) error {
// route handler so that important security checks are done, etc.
primaryRoute := emptyHandler
if srv.Routes != nil {
- // inject the server name for observability purposes
- ctx.Context = contextWithServerName(ctx.Context, srvName)
err := srv.Routes.ProvisionHandlers(ctx)
if err != nil {
return fmt.Errorf("server %s: setting up route handlers: %v", srvName, err)
diff --git a/modules/caddyhttp/metrics.go b/modules/caddyhttp/metrics.go
index dbf1033..2b3b7c7 100644
--- a/modules/caddyhttp/metrics.go
+++ b/modules/caddyhttp/metrics.go
@@ -94,10 +94,6 @@ func serverNameFromContext(ctx context.Context) string {
return srvName
}
-func contextWithServerName(ctx context.Context, serverName string) context.Context {
- return context.WithValue(ctx, ctxKeyServerName{}, serverName)
-}
-
type metricsInstrumentedHandler struct {
labels prometheus.Labels
statusLabels prometheus.Labels
diff --git a/modules/caddyhttp/metrics_test.go b/modules/caddyhttp/metrics_test.go
index 5c3bc1d..14248a3 100644
--- a/modules/caddyhttp/metrics_test.go
+++ b/modules/caddyhttp/metrics_test.go
@@ -1,7 +1,6 @@
package caddyhttp
import (
- "context"
"errors"
"net/http"
"net/http/httptest"
@@ -10,20 +9,6 @@ import (
"github.com/prometheus/client_golang/prometheus/testutil"
)
-func TestServerNameFromContext(t *testing.T) {
- ctx := context.Background()
- expected := "UNKNOWN"
- if actual := serverNameFromContext(ctx); actual != expected {
- t.Errorf("Not equal: expected %q, but got %q", expected, actual)
- }
-
- in := "foo"
- ctx = contextWithServerName(ctx, in)
- if actual := serverNameFromContext(ctx); actual != in {
- t.Errorf("Not equal: expected %q, but got %q", in, actual)
- }
-}
-
func TestMetricsInstrumentedHandler(t *testing.T) {
handlerErr := errors.New("oh noes")
response := []byte("hello world!")