Commit f4c29de7 authored by Jean de Klerk's avatar Jean de Klerk Committed by Brad Fitzpatrick

trace: better error message for double init

Fixes golang/go#24137

Change-Id: Ifcf6449aed32071cdb643028347ec814bffd8d06
Reviewed-on: https://go-review.googlesource.com/127121Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 22bb95c5
...@@ -70,6 +70,7 @@ import ( ...@@ -70,6 +70,7 @@ import (
"log" "log"
"net" "net"
"net/http" "net/http"
"net/url"
"runtime" "runtime"
"sort" "sort"
"strconv" "strconv"
...@@ -110,6 +111,13 @@ var AuthRequest = func(req *http.Request) (any, sensitive bool) { ...@@ -110,6 +111,13 @@ var AuthRequest = func(req *http.Request) (any, sensitive bool) {
} }
func init() { func init() {
_, pat := http.DefaultServeMux.Handler(&http.Request{URL: &url.URL{Path: "/debug/requests"}})
if pat != "" {
panic("/debug/requests is already registered. You may have two independent copies of " +
"golang.org/x/net/trace in your binary, trying to maintain separate state. This may " +
"involve a vendored copy of golang.org/x/net/trace.")
}
// TODO(jbd): Serve Traces from /debug/traces in the future? // TODO(jbd): Serve Traces from /debug/traces in the future?
// There is no requirement for a request to be present to have traces. // There is no requirement for a request to be present to have traces.
http.HandleFunc("/debug/requests", Traces) http.HandleFunc("/debug/requests", Traces)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment