Commit 85267390 authored by Christopher Speller's avatar Christopher Speller Committed by Harrison Healey

MM-10934 Update server dependencies. (#8981)

* Changing throttled import path.

* Upgrading dependencies.
parent a59ccaa8
......@@ -11,7 +11,7 @@
branch = "master"
name = "github.com/armon/go-metrics"
packages = ["."]
revision = "783273d703149aaeb9897cf58613d5af48861c25"
revision = "58588f401c2cc130a7308a52ca3bc6c0a76db04b"
[[projects]]
branch = "master"
......@@ -70,8 +70,8 @@
[[projects]]
name = "github.com/go-ini/ini"
packages = ["."]
revision = "6529cf7c58879c08d927016dde4477f18a0634cb"
version = "v1.36.0"
revision = "06f5f3d67269ccec1fe5fe4134ba6e982984f7f5"
version = "v1.37.0"
[[projects]]
name = "github.com/go-ldap/ldap"
......@@ -91,14 +91,14 @@
"internal/singleflight",
"internal/util"
]
revision = "877867d2845fbaf86798befe410b6ceb6f5c29a3"
version = "v6.10.2"
revision = "83fb42932f6145ce52df09860384a4653d2d332a"
version = "v6.12.0"
[[projects]]
branch = "master"
name = "github.com/go-sql-driver/mysql"
packages = ["."]
revision = "3287d94d4c6a48a63e16fffaabf27ab20203af2a"
revision = "749ddf1598b47e3cd909414bda735fe790ef3d30"
[[projects]]
branch = "master"
......@@ -144,13 +144,13 @@
branch = "master"
name = "github.com/gorilla/websocket"
packages = ["."]
revision = "21ab95fa12b9bdd8fecf5fa3586aad941cc98785"
revision = "5ed622c449da6d44c3c8329331ff47a9e5844f71"
[[projects]]
branch = "master"
name = "github.com/hako/durafmt"
packages = ["."]
revision = "fddaacea1c7eb9c0aa2ec13a6f92e0a4ced16618"
revision = "7b7ae1e72eade09dbc9c2cfba3e6c4bae7b8bcac"
[[projects]]
branch = "master"
......@@ -230,7 +230,7 @@
branch = "master"
name = "github.com/jaytaylor/html2text"
packages = ["."]
revision = "64a82a6d140778896f13303121a49d8cb8007034"
revision = "57d518f124b0cf46ea2021f25a01396b3522e6fb"
[[projects]]
branch = "master"
......@@ -245,7 +245,7 @@
".",
"oid"
]
revision = "d34b9ff171c21ad295489235aec8b6626023cd04"
revision = "90697d60dd844d5ef6ff15135d0203f65d2f53b8"
[[projects]]
name = "github.com/magiconair/properties"
......@@ -262,7 +262,7 @@
"jlexer",
"jwriter"
]
revision = "8b799c424f57fa123fc63a99d6383bc6e4c02578"
revision = "3fdea8d05856a0c8df22ed4bc71b3219245e4485"
[[projects]]
branch = "master"
......@@ -280,6 +280,13 @@
]
revision = "bbaefb05eaa0389ea712340066837c8ce4d287f9"
[[projects]]
branch = "mattermost"
name = "github.com/mattermost/viper"
packages = ["."]
revision = "1b00ce64485c7a2449f239de3cbc9040a9c46aa0"
source = "https://github.com/mattermost/viper"
[[projects]]
name = "github.com/mattn/go-runewidth"
packages = ["."]
......@@ -289,20 +296,20 @@
[[projects]]
name = "github.com/mattn/go-sqlite3"
packages = ["."]
revision = "6c771bb9887719704b210e87e934f08be014bdb1"
version = "v1.6.0"
revision = "25ecb14adfc7543176f7d85291ec7dba82c6f7e4"
version = "v1.9.0"
[[projects]]
name = "github.com/matttproud/golang_protobuf_extensions"
packages = ["pbutil"]
revision = "3247c84500bff8d9fb6d579d800f20b3e091582c"
version = "v1.0.0"
revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c"
version = "v1.0.1"
[[projects]]
name = "github.com/miekg/dns"
packages = ["."]
revision = "e57bf427e68187a27e22adceac868350d7a7079b"
version = "v1.0.7"
revision = "5a2b9fab83ff0f8bfc99684bd5f43a37abe560f1"
version = "v1.0.8"
[[projects]]
name = "github.com/minio/minio-go"
......@@ -314,14 +321,14 @@
"pkg/s3utils",
"pkg/set"
]
revision = "c6108c47ba5d86548404ebf9e51c5ca18769fe79"
version = "6.0.1"
revision = "33b767f5638ccaf7cc30516ec54024d3e58a8209"
version = "v6.0.3"
[[projects]]
branch = "master"
name = "github.com/mitchellh/go-homedir"
packages = ["."]
revision = "b8bc1bf767474819792c23f32d8286a45736f1c6"
revision = "3864e76763d94a6df2f9960b16a20a33da9f9a66"
[[projects]]
branch = "master"
......@@ -355,8 +362,8 @@
[[projects]]
name = "github.com/pelletier/go-toml"
packages = ["."]
revision = "acdc4509485b587f5e675510c4f2c63e90ff68a8"
version = "v1.1.0"
revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194"
version = "v1.2.0"
[[projects]]
name = "github.com/pkg/errors"
......@@ -393,7 +400,7 @@
"internal/bitbucket.org/ww/goautoneg",
"model"
]
revision = "d811d2e9bf898806ecfb6ef6296774b13ffc314c"
revision = "7600349dcfe1abd18d72d3a1770870d9800a7801"
[[projects]]
branch = "master"
......@@ -404,7 +411,7 @@
"nfs",
"xfs"
]
revision = "8b1c2da0d56deffdbb9e48d4414b4e674bd8083e"
revision = "7d6f385de8bea29190f15ba9931442a0eaef9af7"
[[projects]]
branch = "go1"
......@@ -413,7 +420,7 @@
"exif",
"tiff"
]
revision = "fb35d3c3290d09f3524b684b5d42d0063c227158"
revision = "8d986c03457a2057c7b0fb0a48113f7dd48f9619"
[[projects]]
branch = "master"
......@@ -445,8 +452,8 @@
".",
"mem"
]
revision = "63644898a8da0bc22138abf860edaf5277b6102e"
version = "v1.1.0"
revision = "787d034dfe70e44075ccc060d346146ef53270ad"
version = "v1.1.1"
[[projects]]
name = "github.com/spf13/cast"
......@@ -472,13 +479,6 @@
revision = "583c0c0531f06d5278b7d917446061adc344b5cd"
version = "v1.0.1"
[[projects]]
branch = "mattermost"
name = "github.com/mattermost/viper"
packages = ["."]
revision = "1b00ce64485c7a2449f239de3cbc9040a9c46aa0"
source = "https://github.com/mattermost/viper"
[[projects]]
branch = "master"
name = "github.com/ssor/bom"
......@@ -488,8 +488,8 @@
[[projects]]
name = "github.com/stretchr/objx"
packages = ["."]
revision = "facf9a85c22f48d2f52f2380e4efce1768749a89"
version = "v0.1"
revision = "477a77ecc69700c7cdeb1fa9e129548e1c1c393c"
version = "v0.1.1"
[[projects]]
name = "github.com/stretchr/testify"
......@@ -499,8 +499,17 @@
"require",
"suite"
]
revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71"
version = "v1.2.1"
revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686"
version = "v1.2.2"
[[projects]]
name = "github.com/throttled/throttled"
packages = [
".",
"store/memstore"
]
revision = "aeea1c7338e6dd1e1b309afe07fb7bbcfa83c2fa"
version = "v2.2.1"
[[projects]]
name = "github.com/tylerb/graceful"
......@@ -553,7 +562,7 @@
"ed25519/internal/edwards25519",
"ssh/terminal"
]
revision = "1a580b3eff7814fc9b40602fd35256c63b50f491"
revision = "a49355c7e3f8fe157a85be2f77e6e269a0f89602"
[[projects]]
branch = "master"
......@@ -565,24 +574,24 @@
"tiff",
"tiff/lzw"
]
revision = "f315e440302883054d0c2bd85486878cb4f8572c"
revision = "af66defab954cb421ca110193eed9477c8541e2a"
[[projects]]
branch = "release-branch.go1.10"
branch = "master"
name = "golang.org/x/net"
packages = [
"bpf",
"html",
"html/atom",
"html/charset",
"http/httpguts",
"idna",
"internal/iana",
"internal/socket",
"ipv4",
"ipv6",
"lex/httplex"
"ipv6"
]
revision = "0ed95abb35c445290478a5348a7b38bb154135fd"
revision = "afe8f62b1d6bbd81f31868121a50b06d8188e1f9"
[[projects]]
branch = "master"
......@@ -592,7 +601,7 @@
"unix",
"windows"
]
revision = "7c87d13f8e835d2fb3a70a2912c811ed0c1d241b"
revision = "ad87a3a340fa7f3bed189293fbfa7a9b7e021ae1"
[[projects]]
name = "golang.org/x/text"
......@@ -630,8 +639,8 @@
[[projects]]
name = "google.golang.org/appengine"
packages = ["cloudsql"]
revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a"
version = "v1.0.0"
revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
version = "v1.1.0"
[[projects]]
branch = "v3"
......@@ -664,17 +673,8 @@
"config",
"uritemplates"
]
revision = "2562d7254d4655c3bcf34810cdb4ca45e944d53f"
version = "v5.0.68"
[[projects]]
name = "gopkg.in/throttled/throttled.v2"
packages = [
".",
"store/memstore"
]
revision = "b5675e93f9d999b22f92d859a5bf2138d3641af4"
version = "v2.0.3"
revision = "b708306d715bea9b983685e94ab4602cdc9f988b"
version = "v5.0.69"
[[projects]]
name = "gopkg.in/yaml.v2"
......@@ -685,6 +685,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "463ec98eba9cac751c2702ca1ecae98740d7dd9a1dc8b615b484ea4bdb41f6b5"
inputs-digest = "76d5a63bc94bc0a75fe311cbc1df579fdd77b5d039a006236c00ee122ab69c1b"
solver-name = "gps-cdcl"
solver-version = 1
......@@ -14,8 +14,8 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
"github.com/pkg/errors"
throttled "gopkg.in/throttled/throttled.v2"
"gopkg.in/throttled/throttled.v2/store/memstore"
"github.com/throttled/throttled"
"github.com/throttled/throttled/store/memstore"
)
type RateLimiter struct {
......
......@@ -7,7 +7,7 @@ expose application metrics, and profile runtime performance in a flexible manner
Current API: [![GoDoc](https://godoc.org/github.com/armon/go-metrics?status.svg)](https://godoc.org/github.com/armon/go-metrics)
Sinks
=====
-----
The `metrics` package makes use of a `MetricSink` interface to support delivery
to any type of backend. Currently the following sinks are provided:
......@@ -23,8 +23,26 @@ In addition to the sinks, the `InmemSignal` can be used to catch a signal,
and dump a formatted output of recent metrics. For example, when a process gets
a SIGUSR1, it can dump to stderr recent performance metrics for debugging.
Labels
------
Most metrics do have an equivalent ending with `WithLabels`, such methods
allow to push metrics with labels and use some features of underlying Sinks
(ex: translated into Prometheus labels).
Since some of these labels may increase greatly cardinality of metrics, the
library allow to filter labels using a blacklist/whitelist filtering system
which is global to all metrics.
* If `Config.AllowedLabels` is not nil, then only labels specified in this value will be sent to underlying Sink, otherwise, all labels are sent by default.
* If `Config.BlockedLabels` is not nil, any label specified in this value will not be sent to underlying Sinks.
By default, both `Config.AllowedLabels` and `Config.BlockedLabels` are nil, meaning that
no tags are filetered at all, but it allow to a user to globally block some tags with high
cardinality at application level.
Examples
========
--------
Here is an example of using the package:
......@@ -70,5 +88,4 @@ When a signal comes in, output like the following will be dumped to stderr:
[2014-01-28 14:57:33.04 -0800 PST][G] 'foo': 42.000
[2014-01-28 14:57:33.04 -0800 PST][P] 'bar': 30.000
[2014-01-28 14:57:33.04 -0800 PST][C] 'baz': Count: 3 Min: 1.000 Mean: 41.000 Max: 80.000 Stddev: 39.509
[2014-01-28 14:57:33.04 -0800 PST][S] 'method.wow': Count: 3 Min: 22.000 Mean: 54.667 Max: 100.000 Stddev: 40.513
[2014-01-28 14:57:33.04 -0800 PST][S] 'method.wow': Count: 3 Min: 22.000 Mean: 54.667 Max: 100.000 Stddev: 40.513
\ No newline at end of file
......@@ -35,10 +35,11 @@ func (m *Metrics) SetGaugeWithLabels(key []string, val float32, labels []Label)
key = insert(0, m.ServiceName, key)
}
}
if !m.allowMetric(key) {
allowed, labelsFiltered := m.allowMetric(key, labels)
if !allowed {
return
}
m.sink.SetGaugeWithLabels(key, val, labels)
m.sink.SetGaugeWithLabels(key, val, labelsFiltered)
}
func (m *Metrics) EmitKey(key []string, val float32) {
......@@ -48,7 +49,8 @@ func (m *Metrics) EmitKey(key []string, val float32) {
if m.ServiceName != "" {
key = insert(0, m.ServiceName, key)
}
if !m.allowMetric(key) {
allowed, _ := m.allowMetric(key, nil)
if !allowed {
return
}
m.sink.EmitKey(key, val)
......@@ -72,10 +74,11 @@ func (m *Metrics) IncrCounterWithLabels(key []string, val float32, labels []Labe
key = insert(0, m.ServiceName, key)
}
}
if !m.allowMetric(key) {
allowed, labelsFiltered := m.allowMetric(key, labels)
if !allowed {
return
}
m.sink.IncrCounterWithLabels(key, val, labels)
m.sink.IncrCounterWithLabels(key, val, labelsFiltered)
}
func (m *Metrics) AddSample(key []string, val float32) {
......@@ -96,10 +99,11 @@ func (m *Metrics) AddSampleWithLabels(key []string, val float32, labels []Label)
key = insert(0, m.ServiceName, key)
}
}
if !m.allowMetric(key) {
allowed, labelsFiltered := m.allowMetric(key, labels)
if !allowed {
return
}
m.sink.AddSampleWithLabels(key, val, labels)
m.sink.AddSampleWithLabels(key, val, labelsFiltered)
}
func (m *Metrics) MeasureSince(key []string, start time.Time) {
......@@ -120,23 +124,45 @@ func (m *Metrics) MeasureSinceWithLabels(key []string, start time.Time, labels [
key = insert(0, m.ServiceName, key)
}
}
if !m.allowMetric(key) {
allowed, labelsFiltered := m.allowMetric(key, labels)
if !allowed {
return
}
now := time.Now()
elapsed := now.Sub(start)
msec := float32(elapsed.Nanoseconds()) / float32(m.TimerGranularity)
m.sink.AddSampleWithLabels(key, msec, labels)
m.sink.AddSampleWithLabels(key, msec, labelsFiltered)
}
// UpdateFilter overwrites the existing filter with the given rules.
func (m *Metrics) UpdateFilter(allow, block []string) {
m.UpdateFilterAndLabels(allow, block, m.AllowedLabels, m.BlockedLabels)
}
// UpdateFilterAndLabels overwrites the existing filter with the given rules.
func (m *Metrics) UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string) {
m.filterLock.Lock()
defer m.filterLock.Unlock()
m.AllowedPrefixes = allow
m.BlockedPrefixes = block
if allowedLabels == nil {
// Having a white list means we take only elements from it
m.allowedLabels = nil
} else {
m.allowedLabels = make(map[string]bool)
for _, v := range allowedLabels {
m.allowedLabels[v] = true
}
}
m.blockedLabels = make(map[string]bool)
for _, v := range blockedLabels {
m.blockedLabels[v] = true
}
m.AllowedLabels = allowedLabels
m.BlockedLabels = blockedLabels
m.filter = iradix.New()
for _, prefix := range m.AllowedPrefixes {
m.filter, _, _ = m.filter.Insert([]byte(prefix), true)
......@@ -146,20 +172,56 @@ func (m *Metrics) UpdateFilter(allow, block []string) {
}
}
// labelIsAllowed return true if a should be included in metric
// the caller should lock m.filterLock while calling this method
func (m *Metrics) labelIsAllowed(label *Label) bool {
labelName := (*label).Name
if m.blockedLabels != nil {
_, ok := m.blockedLabels[labelName]
if ok {
// If present, let's remove this label
return false
}
}
if m.allowedLabels != nil {
_, ok := m.allowedLabels[labelName]
return ok
}
// Allow by default
return true
}
// filterLabels return only allowed labels
// the caller should lock m.filterLock while calling this method
func (m *Metrics) filterLabels(labels []Label) []Label {
if labels == nil {
return nil
}
toReturn := labels[:0]
for _, label := range labels {
if m.labelIsAllowed(&label) {
toReturn = append(toReturn, label)
}
}
return toReturn
}
// Returns whether the metric should be allowed based on configured prefix filters
func (m *Metrics) allowMetric(key []string) bool {
// Also return the applicable labels
func (m *Metrics) allowMetric(key []string, labels []Label) (bool, []Label) {
m.filterLock.RLock()
defer m.filterLock.RUnlock()
if m.filter == nil || m.filter.Len() == 0 {
return m.Config.FilterDefault
return m.Config.FilterDefault, m.filterLabels(labels)
}
_, allowed, ok := m.filter.Root().LongestPrefix([]byte(strings.Join(key, ".")))
if !ok {
return m.Config.FilterDefault
return m.Config.FilterDefault, m.filterLabels(labels)
}
return allowed.(bool)
return allowed.(bool), m.filterLabels(labels)
}
// Periodically collects runtime stats to publish
......
......@@ -23,6 +23,8 @@ type Config struct {
AllowedPrefixes []string // A list of metric prefixes to allow, with '.' as the separator
BlockedPrefixes []string // A list of metric prefixes to block, with '.' as the separator
AllowedLabels []string // A list of metric labels to allow, with '.' as the separator
BlockedLabels []string // A list of metric labels to block, with '.' as the separator
FilterDefault bool // Whether to allow metrics by default
}
......@@ -30,10 +32,12 @@ type Config struct {
// be used to emit
type Metrics struct {
Config
lastNumGC uint32
sink MetricSink
filter *iradix.Tree
filterLock sync.RWMutex
lastNumGC uint32
sink MetricSink
filter *iradix.Tree
allowedLabels map[string]bool
blockedLabels map[string]bool
filterLock sync.RWMutex // Lock filters and allowedLabels/blockedLabels access
}
// Shared global metrics instance
......@@ -68,7 +72,7 @@ func New(conf *Config, sink MetricSink) (*Metrics, error) {
met := &Metrics{}
met.Config = *conf
met.sink = sink
met.UpdateFilter(conf.AllowedPrefixes, conf.BlockedPrefixes)
met.UpdateFilterAndLabels(conf.AllowedPrefixes, conf.BlockedPrefixes, conf.AllowedLabels, conf.BlockedLabels)
// Start the runtime collector
if conf.EnableRuntimeMetrics {
......@@ -127,3 +131,11 @@ func MeasureSinceWithLabels(key []string, start time.Time, labels []Label) {
func UpdateFilter(allow, block []string) {
globalMetrics.Load().(*Metrics).UpdateFilter(allow, block)
}
// UpdateFilterAndLabels set allow/block prefixes of metrics while allowedLabels
// and blockedLabels - when not nil - allow filtering of labels in order to
// block/allow globally labels (especially useful when having large number of
// values for a given label). See README.md for more information about usage.
func UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels []string) {
globalMetrics.Load().(*Metrics).UpdateFilterAndLabels(allow, block, allowedLabels, blockedLabels)
}
......@@ -13,4 +13,5 @@ script:
- go get github.com/smartystreets/goconvey
- mkdir -p $HOME/gopath/src/gopkg.in
- ln -s $HOME/gopath/src/github.com/go-ini/ini $HOME/gopath/src/gopkg.in/ini.v1
- cd $HOME/gopath/src/gopkg.in/ini.v1
- go test -v -cover -race
......@@ -32,7 +32,7 @@ const (
// Maximum allowed depth when recursively substituing variable names.
_DEPTH_VALUES = 99
_VERSION = "1.36.0"
_VERSION = "1.37.0"
)
// Version returns current package version literal.
......@@ -145,6 +145,11 @@ type LoadOptions struct {
// Relevant quote: Values can also span multiple lines, as long as they are indented deeper
// than the first line of the value.
AllowPythonMultilineValues bool
// SpaceBeforeInlineComment indicates whether to allow comment symbols (\# and \;) inside value.