Skip to content

Instantly share code, notes, and snippets.

@graphaelli
Created May 28, 2019 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphaelli/eb84744c57c0b66b61a131a34db851e5 to your computer and use it in GitHub Desktop.
Save graphaelli/eb84744c57c0b66b61a131a34db851e5 to your computer and use it in GitHub Desktop.
diff --git a/vendor/go.elastic.co/apm/module/apmhttp/handler.go b/vendor/go.elastic.co/apm/module/apmhttp/handler.go
index 2614c2c4..169d2fe5 100644
--- a/vendor/go.elastic.co/apm/module/apmhttp/handler.go
+++ b/vendor/go.elastic.co/apm/module/apmhttp/handler.go
@@ -2,6 +2,8 @@ package apmhttp
import (
"context"
+ "log"
+ "runtime/debug"
"net/http"
"go.elastic.co/apm"
@@ -164,11 +166,18 @@ type Response struct {
type responseWriter struct {
http.ResponseWriter
resp Response
+ writeHeaderCalls [][]byte
}
// WriteHeader sets w.resp.StatusCode and calls through to the embedded
// ResponseWriter.
func (w *responseWriter) WriteHeader(statusCode int) {
+ w.writeHeaderCalls = append(w.writeHeaderCalls, debug.Stack())
+ if len(w.writeHeaderCalls) > 1 {
+ for i, stack := range w.writeHeaderCalls {
+ log.Printf("stack %d:\n%s", i, stack)
+ }
+ }
w.ResponseWriter.WriteHeader(statusCode)
w.resp.StatusCode = statusCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment