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:
Matt Moore 2020-01-09 08:56:56 -08:00 committed by Knative Prow Robot
parent 36171c8542
commit 2937c5b31f
3 changed files with 23 additions and 20 deletions

4
Gopkg.lock generated
View File

@ -940,7 +940,7 @@
[[projects]]
branch = "master"
digest = "1:453e21d9c4385548ef0829f4509961f2d6b19b573fd830a5739a7fea8a8d6290"
digest = "1:b21a3ea7ad9b920c6d1c2b26d11eba1d2ed4ee5d88b03f20f1efd46a6eaab902"
name = "knative.dev/pkg"
packages = [
"apis",
@ -959,7 +959,7 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "298f22bea61fb6a0e8d55546563908e4787f9ac2"
revision = "8c62412074275c22632e23fbe726555bf970ba6c"
[[projects]]
branch = "master"

View File

@ -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.
**This is true today.**
[Ensure this on an ongoing basis.](https://github.com/knative/pkg/issues/957)
- [ ] Google to implement OpenCensus Agent configuration to match what they
are doing for Stackdriver now. (No public issue link because this shoud be
in Google's vendor-specific configuration.)
- [ ] Google to implement OpenCensus Agent configuration to match what they are
doing for Stackdriver now. (No public issue link because this shoud be in
Google's vendor-specific configuration.)
- [ ] Document how to configure OpenCensus/OpenTelemetry Agent + Prometheus to
achieve the current level of application visibility, and determine a
long-term course for how to maintain this as a "bare minimum" supported

View File

@ -21,7 +21,7 @@ import (
"net/http"
"net/http/pprof"
"strconv"
"sync"
"sync/atomic"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
@ -39,10 +39,9 @@ const (
// Handler holds the main HTTP handler and a flag indicating
// whether the handler is active
type Handler struct {
enabled bool
enabledMux sync.Mutex
handler http.Handler
log *zap.SugaredLogger
enabled int32
handler http.Handler
log *zap.SugaredLogger
}
// 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)
logger.Infof("Profiling enabled: %t", enableProfiling)
return &Handler{
enabled: enableProfiling,
enabled: boolToInt32(enableProfiling),
handler: mux,
log: logger,
}
}
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.enabledMux.Lock()
defer h.enabledMux.Unlock()
if h.enabled {
if atomic.LoadInt32(&h.enabled) == 1 {
h.handler.ServeHTTP(w, r)
} else {
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))
return
}
h.enabledMux.Lock()
defer h.enabledMux.Unlock()
if h.enabled != enabled {
h.enabled = enabled
h.log.Infof("Profiling enabled: %t", h.enabled)
new := boolToInt32(enabled)
old := atomic.SwapInt32(&h.enabled, new)
if old != new {
h.log.Infof("Profiling enabled: %t", enabled)
}
}
@ -111,3 +107,10 @@ func NewServer(handler http.Handler) *http.Server {
Handler: handler,
}
}
func boolToInt32(b bool) int32 {
if b {
return 1
}
return 0
}