Update vendor for weaveworks/commont to Tom's fork, for now.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
pull/541/head
Tom Wilkie 6 years ago committed by Tom Wilkie
parent 06f41e793b
commit 13c667c58c
  1. 8
      Gopkg.lock
  2. 3
      Gopkg.toml
  3. 5
      vendor/github.com/weaveworks/common/logging/level.go
  4. 12
      vendor/github.com/weaveworks/common/middleware/grpc_logging.go
  5. 5
      vendor/github.com/weaveworks/common/middleware/logging.go
  6. 16
      vendor/github.com/weaveworks/common/server/server.go

8
Gopkg.lock generated

@ -900,8 +900,8 @@
version = "v2.0.0"
[[projects]]
branch = "master"
digest = "1:81403343bc9a102e3c924f87ad81e5a13bb7c36211714475c906853f4e887933"
branch = "server-listen-addr"
digest = "1:0184d699d4cbbbc3073fbbdd7cc0c8592d484c6f23914c89fb6d218e90de171a"
name = "github.com/weaveworks/common"
packages = [
"aws",
@ -918,7 +918,8 @@
"user",
]
pruneopts = "UT"
revision = "81a1a4d158e60de72dbead600ec011fb90344f8c"
revision = "5bf824591a6567784789cf9b2169f74f162bf80d"
source = "https://github.com/tomwilkie/weaveworks-common"
[[projects]]
digest = "1:bb40f7ff970145324f2a2acafdff3a23ed3f05db49cb5eb519b3d6bee86a5887"
@ -1413,6 +1414,7 @@
"github.com/prometheus/prometheus/pkg/modtimevfs",
"github.com/prometheus/prometheus/pkg/relabel",
"github.com/prometheus/prometheus/pkg/textparse",
"github.com/prometheus/prometheus/promql",
"github.com/prometheus/prometheus/relabel",
"github.com/prometheus/prometheus/template",
"github.com/shurcooL/httpfs/filter",

@ -31,7 +31,8 @@
[[constraint]]
name = "github.com/weaveworks/common"
branch = "master"
source = "https://github.com/tomwilkie/weaveworks-common"
branch = "server-listen-addr"
[[constraint]]
name = "gopkg.in/fsnotify.v1"

@ -49,6 +49,11 @@ func (l *Level) UnmarshalYAML(unmarshal func(interface{}) error) error {
return l.Set(level)
}
// MarshalYAML implements yaml.Marshaler.
func (l Level) MarshalYAML() (interface{}, error) {
return l.String(), nil
}
// Set updates the value of the allowed level. Implments flag.Value.
func (l *Level) Set(s string) error {
switch s {

@ -31,7 +31,11 @@ func (s GRPCServerLog) UnaryServerInterceptor(ctx context.Context, req interface
if s.WithRequest {
entry = entry.WithField("request", req)
}
entry.WithField(errorKey, err).Warnln(gRPC)
if err == context.Canceled {
entry.WithField(errorKey, err).Debugln(gRPC)
} else {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}
@ -44,7 +48,11 @@ func (s GRPCServerLog) StreamServerInterceptor(srv interface{}, ss grpc.ServerSt
err := handler(srv, ss)
entry := user.LogWith(ss.Context(), s.Log).WithFields(logging.Fields{"method": info.FullMethod, "duration": time.Since(begin)})
if err != nil {
entry.WithField(errorKey, err).Warnln(gRPC)
if err == context.Canceled {
entry.WithField(errorKey, err).Debugln(gRPC)
} else {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}

@ -63,8 +63,9 @@ func dumpRequest(req *http.Request) ([]byte, error) {
// Exclude some headers for security, or just that we don't need them when debugging
err := req.Header.WriteSubset(&b, map[string]bool{
"Cookie": true,
"X-Csrf-Token": true,
"Cookie": true,
"X-Csrf-Token": true,
"Authorization": true,
})
if err != nil {
return nil, err

@ -27,7 +27,9 @@ import (
// Config for a Server
type Config struct {
MetricsNamespace string `yaml:"-"`
HTTPListenHost string `yaml:"http_listen_host"`
HTTPListenPort int `yaml:"http_listen_port"`
GRPCListenHost string `yaml:"grpc_listen_host"`
GRPCListenPort int `yaml:"grpc_listen_port"`
RegisterInstrumentation bool `yaml:"-"`
@ -55,7 +57,9 @@ type Config struct {
// RegisterFlags adds the flags required to config this to the given FlagSet
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.StringVar(&cfg.HTTPListenHost, "server.http-listen-host", "", "HTTP server listen host.")
f.IntVar(&cfg.HTTPListenPort, "server.http-listen-port", 80, "HTTP server listen port.")
f.StringVar(&cfg.GRPCListenHost, "server.grpc-listen-host", "", "gRPC server listen host.")
f.IntVar(&cfg.GRPCListenPort, "server.grpc-listen-port", 9095, "gRPC server listen port.")
f.BoolVar(&cfg.RegisterInstrumentation, "server.register-instrumentation", true, "Register the intrumentation handlers (/metrics etc).")
f.DurationVar(&cfg.ServerGracefulShutdownTimeout, "server.graceful-shutdown-timeout", 30*time.Second, "Timeout for graceful shutdowns")
@ -87,12 +91,12 @@ type Server struct {
// New makes a new Server
func New(cfg Config) (*Server, error) {
// Setup listeners first, so we can fail early if the port is in use.
httpListener, err := net.Listen("tcp", fmt.Sprintf(":%d", cfg.HTTPListenPort))
httpListener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", cfg.HTTPListenHost, cfg.HTTPListenPort))
if err != nil {
return nil, err
}
grpcListener, err := net.Listen("tcp", fmt.Sprintf(":%d", cfg.GRPCListenPort))
grpcListener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", cfg.GRPCListenHost, cfg.GRPCListenPort))
if err != nil {
return nil, err
}
@ -150,12 +154,14 @@ func New(cfg Config) (*Server, error) {
// Setup HTTP server
router := mux.NewRouter()
if cfg.RegisterInstrumentation {
RegisterInstrumentation(router)
}
if cfg.PathPrefix != "" {
// Expect metrics and pprof handlers to be prefixed with server's path prefix.
// e.g. /loki/metrics or /loki/debug/pprof
router = router.PathPrefix(cfg.PathPrefix).Subrouter()
}
if cfg.RegisterInstrumentation {
RegisterInstrumentation(router)
}
httpMiddleware := []middleware.Interface{
middleware.Tracer{
RouteMatcher: router,

Loading…
Cancel
Save