mirror of https://github.com/knative/caching.git
Auto-update dependencies (#178)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign n3wscott /cc n3wscott
This commit is contained in:
parent
36171c8542
commit
2937c5b31f
|
|
@ -940,7 +940,7 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:453e21d9c4385548ef0829f4509961f2d6b19b573fd830a5739a7fea8a8d6290"
|
digest = "1:b21a3ea7ad9b920c6d1c2b26d11eba1d2ed4ee5d88b03f20f1efd46a6eaab902"
|
||||||
name = "knative.dev/pkg"
|
name = "knative.dev/pkg"
|
||||||
packages = [
|
packages = [
|
||||||
"apis",
|
"apis",
|
||||||
|
|
@ -959,7 +959,7 @@
|
||||||
"metrics/metricskey",
|
"metrics/metricskey",
|
||||||
]
|
]
|
||||||
pruneopts = "T"
|
pruneopts = "T"
|
||||||
revision = "298f22bea61fb6a0e8d55546563908e4787f9ac2"
|
revision = "8c62412074275c22632e23fbe726555bf970ba6c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,9 @@ statistics for a short period of time if not.
|
||||||
- [ ] Ensure that all tests pass in a non-Google-Cloud connected environment.
|
- [ ] Ensure that all tests pass in a non-Google-Cloud connected environment.
|
||||||
**This is true today.**
|
**This is true today.**
|
||||||
[Ensure this on an ongoing basis.](https://github.com/knative/pkg/issues/957)
|
[Ensure this on an ongoing basis.](https://github.com/knative/pkg/issues/957)
|
||||||
- [ ] Google to implement OpenCensus Agent configuration to match what they
|
- [ ] Google to implement OpenCensus Agent configuration to match what they are
|
||||||
are doing for Stackdriver now. (No public issue link because this shoud be
|
doing for Stackdriver now. (No public issue link because this shoud be in
|
||||||
in Google's vendor-specific configuration.)
|
Google's vendor-specific configuration.)
|
||||||
- [ ] Document how to configure OpenCensus/OpenTelemetry Agent + Prometheus to
|
- [ ] Document how to configure OpenCensus/OpenTelemetry Agent + Prometheus to
|
||||||
achieve the current level of application visibility, and determine a
|
achieve the current level of application visibility, and determine a
|
||||||
long-term course for how to maintain this as a "bare minimum" supported
|
long-term course for how to maintain this as a "bare minimum" supported
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync/atomic"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
|
@ -39,10 +39,9 @@ const (
|
||||||
// Handler holds the main HTTP handler and a flag indicating
|
// Handler holds the main HTTP handler and a flag indicating
|
||||||
// whether the handler is active
|
// whether the handler is active
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
enabled bool
|
enabled int32
|
||||||
enabledMux sync.Mutex
|
handler http.Handler
|
||||||
handler http.Handler
|
log *zap.SugaredLogger
|
||||||
log *zap.SugaredLogger
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHandler create a new ProfilingHandler which serves runtime profiling data
|
// NewHandler create a new ProfilingHandler which serves runtime profiling data
|
||||||
|
|
@ -58,18 +57,15 @@ func NewHandler(logger *zap.SugaredLogger, enableProfiling bool) *Handler {
|
||||||
mux.HandleFunc(pprofPrefix+"trace", pprof.Trace)
|
mux.HandleFunc(pprofPrefix+"trace", pprof.Trace)
|
||||||
|
|
||||||
logger.Infof("Profiling enabled: %t", enableProfiling)
|
logger.Infof("Profiling enabled: %t", enableProfiling)
|
||||||
|
|
||||||
return &Handler{
|
return &Handler{
|
||||||
enabled: enableProfiling,
|
enabled: boolToInt32(enableProfiling),
|
||||||
handler: mux,
|
handler: mux,
|
||||||
log: logger,
|
log: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
h.enabledMux.Lock()
|
if atomic.LoadInt32(&h.enabled) == 1 {
|
||||||
defer h.enabledMux.Unlock()
|
|
||||||
if h.enabled {
|
|
||||||
h.handler.ServeHTTP(w, r)
|
h.handler.ServeHTTP(w, r)
|
||||||
} else {
|
} else {
|
||||||
http.NotFoundHandler().ServeHTTP(w, r)
|
http.NotFoundHandler().ServeHTTP(w, r)
|
||||||
|
|
@ -96,11 +92,11 @@ func (h *Handler) UpdateFromConfigMap(configMap *corev1.ConfigMap) {
|
||||||
h.log.Errorw("Failed to update the profiling flag", zap.Error(err))
|
h.log.Errorw("Failed to update the profiling flag", zap.Error(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.enabledMux.Lock()
|
|
||||||
defer h.enabledMux.Unlock()
|
new := boolToInt32(enabled)
|
||||||
if h.enabled != enabled {
|
old := atomic.SwapInt32(&h.enabled, new)
|
||||||
h.enabled = enabled
|
if old != new {
|
||||||
h.log.Infof("Profiling enabled: %t", h.enabled)
|
h.log.Infof("Profiling enabled: %t", enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,3 +107,10 @@ func NewServer(handler http.Handler) *http.Server {
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func boolToInt32(b bool) int32 {
|
||||||
|
if b {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue