| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"code.google.com/p/go.net/websocket" |
| 7 | 7 |
"encoding/base64" |
| 8 | 8 |
"encoding/json" |
| 9 |
+ "expvar" |
|
| 9 | 10 |
"fmt" |
| 10 | 11 |
"github.com/dotcloud/docker/archive" |
| 11 | 12 |
"github.com/dotcloud/docker/auth" |
| ... | ... |
@@ -1063,7 +1064,23 @@ func makeHttpHandler(srv *Server, logging bool, localMethod string, localRoute s |
| 1063 | 1063 |
} |
| 1064 | 1064 |
} |
| 1065 | 1065 |
|
| 1066 |
+// Replicated from expvar.go as not public. |
|
| 1067 |
+func expvarHandler(w http.ResponseWriter, r *http.Request) {
|
|
| 1068 |
+ w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
| 1069 |
+ fmt.Fprintf(w, "{\n")
|
|
| 1070 |
+ first := true |
|
| 1071 |
+ expvar.Do(func(kv expvar.KeyValue) {
|
|
| 1072 |
+ if !first {
|
|
| 1073 |
+ fmt.Fprintf(w, ",\n") |
|
| 1074 |
+ } |
|
| 1075 |
+ first = false |
|
| 1076 |
+ fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) |
|
| 1077 |
+ }) |
|
| 1078 |
+ fmt.Fprintf(w, "\n}\n") |
|
| 1079 |
+} |
|
| 1080 |
+ |
|
| 1066 | 1081 |
func AttachProfiler(router *mux.Router) {
|
| 1082 |
+ router.HandleFunc("/debug/vars", expvarHandler)
|
|
| 1067 | 1083 |
router.HandleFunc("/debug/pprof/", pprof.Index)
|
| 1068 | 1084 |
router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
| 1069 | 1085 |
router.HandleFunc("/debug/pprof/profile", pprof.Profile)
|