Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
tools
tabacco
Commits
5d7f1781
Commit
5d7f1781
authored
Jun 09, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dependencies
parent
0a942736
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
2087 additions
and
338 deletions
+2087
-338
vendor/git.autistici.org/ai3/go-common/README.md
vendor/git.autistici.org/ai3/go-common/README.md
+6
-3
vendor/github.com/prometheus/client_golang/prometheus/collector.go
...thub.com/prometheus/client_golang/prometheus/collector.go
+1
-1
vendor/github.com/prometheus/client_golang/prometheus/desc.go
...or/github.com/prometheus/client_golang/prometheus/desc.go
+2
-2
vendor/github.com/prometheus/client_golang/prometheus/doc.go
vendor/github.com/prometheus/client_golang/prometheus/doc.go
+3
-3
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
...thub.com/prometheus/client_golang/prometheus/histogram.go
+45
-73
vendor/github.com/prometheus/client_golang/prometheus/http.go
...or/github.com/prometheus/client_golang/prometheus/http.go
+0
-1
vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go
...prometheus/client_golang/prometheus/promhttp/delegator.go
+0
-1
vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go
....com/prometheus/client_golang/prometheus/promhttp/http.go
+0
-1
vendor/github.com/prometheus/client_golang/prometheus/registry.go
...ithub.com/prometheus/client_golang/prometheus/registry.go
+10
-4
vendor/github.com/prometheus/client_golang/prometheus/summary.go
...github.com/prometheus/client_golang/prometheus/summary.go
+124
-1
vendor/github.com/prometheus/client_golang/prometheus/timer.go
...r/github.com/prometheus/client_golang/prometheus/timer.go
+7
-4
vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
...eus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
+3
-3
vendor/github.com/prometheus/common/model/metric.go
vendor/github.com/prometheus/common/model/metric.go
+0
-1
vendor/github.com/prometheus/procfs/MAINTAINERS.md
vendor/github.com/prometheus/procfs/MAINTAINERS.md
+2
-1
vendor/github.com/prometheus/procfs/Makefile
vendor/github.com/prometheus/procfs/Makefile
+8
-57
vendor/github.com/prometheus/procfs/Makefile.common
vendor/github.com/prometheus/procfs/Makefile.common
+223
-0
vendor/github.com/prometheus/procfs/fixtures.ttar
vendor/github.com/prometheus/procfs/fixtures.ttar
+1339
-87
vendor/github.com/prometheus/procfs/fs.go
vendor/github.com/prometheus/procfs/fs.go
+0
-36
vendor/github.com/prometheus/procfs/go.mod
vendor/github.com/prometheus/procfs/go.mod
+3
-0
vendor/github.com/prometheus/procfs/go.sum
vendor/github.com/prometheus/procfs/go.sum
+2
-0
vendor/github.com/prometheus/procfs/internal/util/parse.go
vendor/github.com/prometheus/procfs/internal/util/parse.go
+14
-0
vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go
...github.com/prometheus/procfs/internal/util/sysreadfile.go
+1
-1
vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go
...com/prometheus/procfs/internal/util/sysreadfile_compat.go
+26
-0
vendor/github.com/prometheus/procfs/mountstats.go
vendor/github.com/prometheus/procfs/mountstats.go
+10
-0
vendor/github.com/prometheus/procfs/nfs/nfs.go
vendor/github.com/prometheus/procfs/nfs/nfs.go
+29
-0
vendor/github.com/prometheus/procfs/proc_psi.go
vendor/github.com/prometheus/procfs/proc_psi.go
+110
-0
vendor/github.com/prometheus/procfs/proc_stat.go
vendor/github.com/prometheus/procfs/proc_stat.go
+2
-2
vendor/github.com/prometheus/procfs/xfs/parse.go
vendor/github.com/prometheus/procfs/xfs/parse.go
+9
-9
vendor/github.com/prometheus/procfs/xfs/xfs.go
vendor/github.com/prometheus/procfs/xfs/xfs.go
+52
-0
vendor/golang.org/x/sync/singleflight/singleflight.go
vendor/golang.org/x/sync/singleflight/singleflight.go
+10
-1
vendor/vendor.json
vendor/vendor.json
+46
-46
No files found.
vendor/git.autistici.org/ai3/go-common/README.md
View file @
5d7f1781
...
...
@@ -9,9 +9,13 @@ A quick overview of the contents:
"RPC" implementation, just JSON POST requests but with retries,
backoff, timeouts, tracing, etc.
*
[
server implementation of a line-based protocol over a UNIX socket
](
unix/
)
*
[
server implementation of a generic line-based protocol over a UNIX
socket
](
unix/
)
.
*
a
[
LDAP connection pool
](
ldap/
)
*
a
[
LDAP connection pool
](
ldap/
)
.
*
utilities to
[
serialize composite data types
](
ldap/compositetypes/
)
used in our LDAP database.
*
a
[
password hashing library
](
pwhash/
)
that uses fancy advanced
crypto by default but is also backwards compatible with old
...
...
@@ -19,4 +23,3 @@ A quick overview of the contents:
*
utilities to
[
manage encryption keys
](
userenckey/
)
, themselves
encrypted with a password and a KDF.
vendor/github.com/prometheus/client_golang/prometheus/collector.go
View file @
5d7f1781
...
...
@@ -79,7 +79,7 @@ type Collector interface {
// of the Describe method. If a Collector sometimes collects no metrics at all
// (for example vectors like CounterVec, GaugeVec, etc., which only collect
// metrics after a metric with a fully specified label set has been accessed),
// it might even get registered as an unchecked Collect
e
r (cf. the Register
// it might even get registered as an unchecked Collect
o
r (cf. the Register
// method of the Registerer interface). Hence, only use this shortcut
// implementation of Describe if you are certain to fulfill the contract.
//
...
...
vendor/github.com/prometheus/client_golang/prometheus/desc.go
View file @
5d7f1781
...
...
@@ -93,7 +93,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
// First add only the const label names and sort them...
for
labelName
:=
range
constLabels
{
if
!
checkLabelName
(
labelName
)
{
d
.
err
=
fmt
.
Errorf
(
"%q is not a valid label name
"
,
label
Name
)
d
.
err
=
fmt
.
Errorf
(
"%q is not a valid label name
for metric %q"
,
labelName
,
fq
Name
)
return
d
}
labelNames
=
append
(
labelNames
,
labelName
)
...
...
@@ -115,7 +115,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
// dimension with a different mix between preset and variable labels.
for
_
,
labelName
:=
range
variableLabels
{
if
!
checkLabelName
(
labelName
)
{
d
.
err
=
fmt
.
Errorf
(
"%q is not a valid label name
"
,
label
Name
)
d
.
err
=
fmt
.
Errorf
(
"%q is not a valid label name
for metric %q"
,
labelName
,
fq
Name
)
return
d
}
labelNames
=
append
(
labelNames
,
"$"
+
labelName
)
...
...
vendor/github.com/prometheus/client_golang/prometheus/doc.go
View file @
5d7f1781
...
...
@@ -122,13 +122,13 @@
// the Collect method. The Describe method has to return separate Desc
// instances, representative of the “throw-away” metrics to be created later.
// NewDesc comes in handy to create those Desc instances. Alternatively, you
// could return no Desc at all, which will mark
e
the Collector “unchecked”. No
// checks are p
o
rformed at registration time, but metric consistency will still
// could return no Desc at all, which will mark the Collector “unchecked”. No
// checks are p
e
rformed at registration time, but metric consistency will still
// be ensured at scrape time, i.e. any inconsistencies will lead to scrape
// errors. Thus, with unchecked Collectors, the responsibility to not collect
// metrics that lead to inconsistencies in the total scrape result lies with the
// implementer of the Collector. While this is not a desirable state, it is
// sometimes necessary. The typical use case is a situatio
s
where the exact
// sometimes necessary. The typical use case is a situatio
n
where the exact
// metrics to be returned by a Collector cannot be predicted at registration
// time, but the implementer has sufficient knowledge of the whole system to
// guarantee metric consistency.
...
...
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
View file @
5d7f1781
...
...
@@ -204,8 +204,8 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
}
}
}
// Finally we know the final length of h.upperBounds and can make
coun
ts
// for both
state
s:
// Finally we know the final length of h.upperBounds and can make
bucke
ts
// for both
count
s:
h
.
counts
[
0
]
.
buckets
=
make
([]
uint64
,
len
(
h
.
upperBounds
))
h
.
counts
[
1
]
.
buckets
=
make
([]
uint64
,
len
(
h
.
upperBounds
))
...
...
@@ -224,18 +224,21 @@ type histogramCounts struct {
}
type
histogram
struct
{
// countAndHotIdx is a complicated one. For lock-free yet atomic
// observations, we need to save the total count of observations again,
// combined with the index of the currently-hot counts struct, so that
// we can perform the operation on both values atomically. The least
// significant bit defines the hot counts struct. The remaining 63 bits
// represent the total count of observations. This happens under the
// assumption that the 63bit count will never overflow. Rationale: An
// observations takes about 30ns. Let's assume it could happen in
// 10ns. Overflowing the counter will then take at least (2^63)*10ns,
// which is about 3000 years.
// countAndHotIdx enables lock-free writes with use of atomic updates.
// The most significant bit is the hot index [0 or 1] of the count field
// below. Observe calls update the hot one. All remaining bits count the
// number of Observe calls. Observe starts by incrementing this counter,
// and finish by incrementing the count field in the respective
// histogramCounts, as a marker for completion.
//
// This has to be first in the struct for 64bit alignment. See
// Calls of the Write method (which are non-mutating reads from the
// perspective of the histogram) swap the hot–cold under the writeMtx
// lock. A cooldown is awaited (while locked) by comparing the number of
// observations with the initiation count. Once they match, then the
// last observation on the now cool one has completed. All cool fields must
// be merged into the new hot before releasing writeMtx.
//
// Fields with atomic access first! See alignment constraint:
// http://golang.org/pkg/sync/atomic/#pkg-note-BUG
countAndHotIdx
uint64
...
...
@@ -243,16 +246,14 @@ type histogram struct {
desc
*
Desc
writeMtx
sync
.
Mutex
// Only used in the Write method.
upperBounds
[]
float64
// Two counts, one is "hot" for lock-free observations, the other is
// "cold" for writing out a dto.Metric. It has to be an array of
// pointers to guarantee 64bit alignment of the histogramCounts, see
// http://golang.org/pkg/sync/atomic/#pkg-note-BUG.
counts
[
2
]
*
histogramCounts
hotIdx
int
// Index of currently-hot counts. Only used within Write.
labelPairs
[]
*
dto
.
LabelPair
upperBounds
[]
float64
labelPairs
[]
*
dto
.
LabelPair
}
func
(
h
*
histogram
)
Desc
()
*
Desc
{
...
...
@@ -271,11 +272,11 @@ func (h *histogram) Observe(v float64) {
// 300 buckets: 154 ns/op linear - binary 61.6 ns/op
i
:=
sort
.
SearchFloat64s
(
h
.
upperBounds
,
v
)
// We increment h.countAndHotIdx
by 2
so that the counter in the
upp
er
// 63 bits gets incremented
by 1
. At the same time, we get the new value
// We increment h.countAndHotIdx so that the counter in the
low
er
// 63 bits gets incremented. At the same time, we get the new value
// back, which we can use to find the currently-hot counts.
n
:=
atomic
.
AddUint64
(
&
h
.
countAndHotIdx
,
2
)
hotCounts
:=
h
.
counts
[
n
%
2
]
n
:=
atomic
.
AddUint64
(
&
h
.
countAndHotIdx
,
1
)
hotCounts
:=
h
.
counts
[
n
>>
63
]
if
i
<
len
(
h
.
upperBounds
)
{
atomic
.
AddUint64
(
&
hotCounts
.
buckets
[
i
],
1
)
...
...
@@ -293,72 +294,43 @@ func (h *histogram) Observe(v float64) {
}
func
(
h
*
histogram
)
Write
(
out
*
dto
.
Metric
)
error
{
var
(
his
=
&
dto
.
Histogram
{}
buckets
=
make
([]
*
dto
.
Bucket
,
len
(
h
.
upperBounds
))
hotCounts
,
coldCounts
*
histogramCounts
count
uint64
)
// For simplicity, we mutex the rest of this method. It is not in the
// hot path, i.e. Observe is called much more often than Write. The
// complication of making Write lock-free isn't worth it.
// For simplicity, we protect this whole method by a mutex. It is not in
// the hot path, i.e. Observe is called much more often than Write. The
// complication of making Write lock-free isn't worth it, if possible at
// all.
h
.
writeMtx
.
Lock
()
defer
h
.
writeMtx
.
Unlock
()
// This is a bit arcane, which is why the following spells out this if
// clause in English:
//
// If the currently-hot counts struct is #0, we atomically increment
// h.countAndHotIdx by 1 so that from now on Observe will use the counts
// struct #1. Furthermore, the atomic increment gives us the new value,
// which, in its most significant 63 bits, tells us the count of
// observations done so far up to and including currently ongoing
// observations still using the counts struct just changed from hot to
// cold. To have a normal uint64 for the count, we bitshift by 1 and
// save the result in count. We also set h.hotIdx to 1 for the next
// Write call, and we will refer to counts #1 as hotCounts and to counts
// #0 as coldCounts.
//
// If the currently-hot counts struct is #1, we do the corresponding
// things the other way round. We have to _decrement_ h.countAndHotIdx
// (which is a bit arcane in itself, as we have to express -1 with an
// unsigned int...).
if
h
.
hotIdx
==
0
{
count
=
atomic
.
AddUint64
(
&
h
.
countAndHotIdx
,
1
)
>>
1
h
.
hotIdx
=
1
hotCounts
=
h
.
counts
[
1
]
coldCounts
=
h
.
counts
[
0
]
}
else
{
count
=
atomic
.
AddUint64
(
&
h
.
countAndHotIdx
,
^
uint64
(
0
))
>>
1
// Decrement.
h
.
hotIdx
=
0
hotCounts
=
h
.
counts
[
0
]
coldCounts
=
h
.
counts
[
1
]
}
// Now we have to wait for the now-declared-cold counts to actually cool
// down, i.e. wait for all observations still using it to finish. That's
// the case once the count in the cold counts struct is the same as the
// one atomically retrieved from the upper 63bits of h.countAndHotIdx.
for
{
if
count
==
atomic
.
LoadUint64
(
&
coldCounts
.
count
)
{
break
}
// Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0)
// without touching the count bits. See the struct comments for a full
// description of the algorithm.
n
:=
atomic
.
AddUint64
(
&
h
.
countAndHotIdx
,
1
<<
63
)
// count is contained unchanged in the lower 63 bits.
count
:=
n
&
((
1
<<
63
)
-
1
)
// The most significant bit tells us which counts is hot. The complement
// is thus the cold one.
hotCounts
:=
h
.
counts
[
n
>>
63
]
coldCounts
:=
h
.
counts
[(
^
n
)
>>
63
]
// Await cooldown.
for
count
!=
atomic
.
LoadUint64
(
&
coldCounts
.
count
)
{
runtime
.
Gosched
()
// Let observations get work done.
}
his
.
SampleCount
=
proto
.
Uint64
(
count
)
his
.
SampleSum
=
proto
.
Float64
(
math
.
Float64frombits
(
atomic
.
LoadUint64
(
&
coldCounts
.
sumBits
)))
his
:=
&
dto
.
Histogram
{
Bucket
:
make
([]
*
dto
.
Bucket
,
len
(
h
.
upperBounds
)),
SampleCount
:
proto
.
Uint64
(
count
),
SampleSum
:
proto
.
Float64
(
math
.
Float64frombits
(
atomic
.
LoadUint64
(
&
coldCounts
.
sumBits
))),
}
var
cumCount
uint64
for
i
,
upperBound
:=
range
h
.
upperBounds
{
cumCount
+=
atomic
.
LoadUint64
(
&
coldCounts
.
buckets
[
i
])
b
ucket
s
[
i
]
=
&
dto
.
Bucket
{
his
.
B
ucket
[
i
]
=
&
dto
.
Bucket
{
CumulativeCount
:
proto
.
Uint64
(
cumCount
),
UpperBound
:
proto
.
Float64
(
upperBound
),
}
}
his
.
Bucket
=
buckets
out
.
Histogram
=
his
out
.
Label
=
h
.
labelPairs
...
...
vendor/github.com/prometheus/client_golang/prometheus/http.go
View file @
5d7f1781
...
...
@@ -34,7 +34,6 @@ import (
const
(
contentTypeHeader
=
"Content-Type"
contentLengthHeader
=
"Content-Length"
contentEncodingHeader
=
"Content-Encoding"
acceptEncodingHeader
=
"Accept-Encoding"
)
...
...
vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go
View file @
5d7f1781
...
...
@@ -38,7 +38,6 @@ type delegator interface {
type
responseWriterDelegator
struct
{
http
.
ResponseWriter
handler
,
method
string
status
int
written
int64
wroteHeader
bool
...
...
vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go
View file @
5d7f1781
...
...
@@ -47,7 +47,6 @@ import (
const
(
contentTypeHeader
=
"Content-Type"
contentLengthHeader
=
"Content-Length"
contentEncodingHeader
=
"Content-Encoding"
acceptEncodingHeader
=
"Accept-Encoding"
)
...
...
vendor/github.com/prometheus/client_golang/prometheus/registry.go
View file @
5d7f1781
...
...
@@ -680,7 +680,7 @@ func processMetric(
// Gatherers is a slice of Gatherer instances that implements the Gatherer
// interface itself. Its Gather method calls Gather on all Gatherers in the
// slice in order and returns the merged results. Errors returned from the
// Gather call
e
s are all returned in a flattened MultiError. Duplicate and
// Gather calls are all returned in a flattened MultiError. Duplicate and
// inconsistent Metrics are skipped (first occurrence in slice order wins) and
// reported in the returned error.
//
...
...
@@ -872,7 +872,13 @@ func checkMetricConsistency(
h
=
hashAddByte
(
h
,
separatorByte
)
// Make sure label pairs are sorted. We depend on it for the consistency
// check.
sort
.
Sort
(
labelPairSorter
(
dtoMetric
.
Label
))
if
!
sort
.
IsSorted
(
labelPairSorter
(
dtoMetric
.
Label
))
{
// We cannot sort dtoMetric.Label in place as it is immutable by contract.
copiedLabels
:=
make
([]
*
dto
.
LabelPair
,
len
(
dtoMetric
.
Label
))
copy
(
copiedLabels
,
dtoMetric
.
Label
)
sort
.
Sort
(
labelPairSorter
(
copiedLabels
))
dtoMetric
.
Label
=
copiedLabels
}
for
_
,
lp
:=
range
dtoMetric
.
Label
{
h
=
hashAdd
(
h
,
lp
.
GetName
())
h
=
hashAddByte
(
h
,
separatorByte
)
...
...
@@ -903,8 +909,8 @@ func checkDescConsistency(
}
// Is the desc consistent with the content of the metric?
lpsFromDesc
:=
make
([]
*
dto
.
LabelPair
,
0
,
len
(
dtoMetric
.
Label
))
lpsFromDesc
=
append
(
lpsFromDesc
,
desc
.
constLabelPairs
...
)
lpsFromDesc
:=
make
([]
*
dto
.
LabelPair
,
len
(
desc
.
constLabelPairs
)
,
len
(
dtoMetric
.
Label
))
copy
(
lpsFromDesc
,
desc
.
constLabelPairs
)
for
_
,
l
:=
range
desc
.
variableLabels
{
lpsFromDesc
=
append
(
lpsFromDesc
,
&
dto
.
LabelPair
{
Name
:
proto
.
String
(
l
),
...
...
vendor/github.com/prometheus/client_golang/prometheus/summary.go
View file @
5d7f1781
...
...
@@ -16,8 +16,10 @@ package prometheus
import
(
"fmt"
"math"
"runtime"
"sort"
"sync"
"sync/atomic"
"time"
"github.com/beorn7/perks/quantile"
...
...
@@ -151,7 +153,7 @@ type SummaryOpts struct {
BufCap
uint32
}
//
Great fuck-up
with the sliding-window decay algorithm... The Merge method of
//
Problem
with the sliding-window decay algorithm... The Merge method of
// perk/quantile is actually not working as advertised - and it might be
// unfixable, as the underlying algorithm is apparently not capable of merging
// summaries in the first place. To avoid using Merge, we are currently adding
...
...
@@ -214,6 +216,17 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
opts
.
BufCap
=
DefBufCap
}
if
len
(
opts
.
Objectives
)
==
0
{
// Use the lock-free implementation of a Summary without objectives.
s
:=
&
noObjectivesSummary
{
desc
:
desc
,
labelPairs
:
makeLabelPairs
(
desc
,
labelValues
),
counts
:
[
2
]
*
summaryCounts
{
&
summaryCounts
{},
&
summaryCounts
{}},
}
s
.
init
(
s
)
// Init self-collection.
return
s
}
s
:=
&
summary
{
desc
:
desc
,
...
...
@@ -382,6 +395,116 @@ func (s *summary) swapBufs(now time.Time) {
}
}
type
summaryCounts
struct
{
// sumBits contains the bits of the float64 representing the sum of all
// observations. sumBits and count have to go first in the struct to
// guarantee alignment for atomic operations.
// http://golang.org/pkg/sync/atomic/#pkg-note-BUG
sumBits
uint64
count
uint64
}
type
noObjectivesSummary
struct
{
// countAndHotIdx enables lock-free writes with use of atomic updates.
// The most significant bit is the hot index [0 or 1] of the count field
// below. Observe calls update the hot one. All remaining bits count the
// number of Observe calls. Observe starts by incrementing this counter,
// and finish by incrementing the count field in the respective
// summaryCounts, as a marker for completion.
//
// Calls of the Write method (which are non-mutating reads from the
// perspective of the summary) swap the hot–cold under the writeMtx
// lock. A cooldown is awaited (while locked) by comparing the number of
// observations with the initiation count. Once they match, then the
// last observation on the now cool one has completed. All cool fields must
// be merged into the new hot before releasing writeMtx.
// Fields with atomic access first! See alignment constraint:
// http://golang.org/pkg/sync/atomic/#pkg-note-BUG
countAndHotIdx
uint64
selfCollector
desc
*
Desc
writeMtx
sync
.
Mutex
// Only used in the Write method.
// Two counts, one is "hot" for lock-free observations, the other is
// "cold" for writing out a dto.Metric. It has to be an array of
// pointers to guarantee 64bit alignment of the histogramCounts, see
// http://golang.org/pkg/sync/atomic/#pkg-note-BUG.
counts
[
2
]
*
summaryCounts
labelPairs
[]
*
dto
.
LabelPair
}
func
(
s
*
noObjectivesSummary
)
Desc
()
*
Desc
{
return
s
.
desc
}
func
(
s
*
noObjectivesSummary
)
Observe
(
v
float64
)
{
// We increment h.countAndHotIdx so that the counter in the lower
// 63 bits gets incremented. At the same time, we get the new value
// back, which we can use to find the currently-hot counts.
n
:=
atomic
.
AddUint64
(
&
s
.
countAndHotIdx
,
1
)
hotCounts
:=
s
.
counts
[
n
>>
63
]
for
{
oldBits
:=
atomic
.
LoadUint64
(
&
hotCounts
.
sumBits
)
newBits
:=
math
.
Float64bits
(
math
.
Float64frombits
(
oldBits
)
+
v
)
if
atomic
.
CompareAndSwapUint64
(
&
hotCounts
.
sumBits
,
oldBits
,
newBits
)
{
break
}
}
// Increment count last as we take it as a signal that the observation
// is complete.
atomic
.
AddUint64
(
&
hotCounts
.
count
,
1
)
}
func
(
s
*
noObjectivesSummary
)
Write
(
out
*
dto
.
Metric
)
error
{
// For simplicity, we protect this whole method by a mutex. It is not in
// the hot path, i.e. Observe is called much more often than Write. The
// complication of making Write lock-free isn't worth it, if possible at
// all.
s
.
writeMtx
.
Lock
()
defer
s
.
writeMtx
.
Unlock
()
// Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0)
// without touching the count bits. See the struct comments for a full
// description of the algorithm.
n
:=
atomic
.
AddUint64
(
&
s
.
countAndHotIdx
,
1
<<
63
)
// count is contained unchanged in the lower 63 bits.
count
:=
n
&
((
1
<<
63
)
-
1
)
// The most significant bit tells us which counts is hot. The complement
// is thus the cold one.
hotCounts
:=
s
.
counts
[
n
>>
63
]
coldCounts
:=
s
.
counts
[(
^
n
)
>>
63
]
// Await cooldown.
for
count
!=
atomic
.
LoadUint64
(
&
coldCounts
.
count
)
{
runtime
.
Gosched
()
// Let observations get work done.
}
sum
:=
&
dto
.
Summary
{
SampleCount
:
proto
.
Uint64
(
count
),
SampleSum
:
proto
.
Float64
(
math
.
Float64frombits
(
atomic
.
LoadUint64
(
&
coldCounts
.
sumBits
))),
}
out
.
Summary
=
sum
out
.
Label
=
s
.
labelPairs
// Finally add all the cold counts to the new hot counts and reset the cold counts.
atomic
.
AddUint64
(
&
hotCounts
.
count
,
count
)
atomic
.
StoreUint64
(
&
coldCounts
.
count
,
0
)
for
{
oldBits
:=
atomic
.
LoadUint64
(
&
hotCounts
.
sumBits
)
newBits
:=
math
.
Float64bits
(
math
.
Float64frombits
(
oldBits
)
+
sum
.
GetSampleSum
())
if
atomic
.
CompareAndSwapUint64
(
&
hotCounts
.
sumBits
,
oldBits
,
newBits
)
{
atomic
.
StoreUint64
(
&
coldCounts
.
sumBits
,
0
)
break
}
}
return
nil
}
type
quantSort
[]
*
dto
.
Quantile
func
(
s
quantSort
)
Len
()
int
{
...
...
vendor/github.com/prometheus/client_golang/prometheus/timer.go
View file @
5d7f1781
...
...
@@ -39,13 +39,16 @@ func NewTimer(o Observer) *Timer {
// ObserveDuration records the duration passed since the Timer was created with
// NewTimer. It calls the Observe method of the Observer provided during
// construction with the duration in seconds as an argument. ObserveDuration is
// usually called with a defer statement.
// construction with the duration in seconds as an argument. The observed
// duration is also returned. ObserveDuration is usually called with a defer
// statement.
//
// Note that this method is only guaranteed to never observe negative durations
// if used with Go1.9+.
func
(
t
*
Timer
)
ObserveDuration
()
{
func
(
t
*
Timer
)
ObserveDuration
()
time
.
Duration
{
d
:=
time
.
Since
(
t
.
begin
)
if
t
.
observer
!=
nil
{
t
.
observer
.
Observe
(
time
.
Since
(
t
.
begin
)
.
Seconds
())
t
.
observer
.
Observe
(
d
.
Seconds
())
}
return
d
}
vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
View file @
5d7f1781
/*
Copyright (c) 2011, Open Knowledge Foundation Ltd.
All rights reserved.
HTTP Content-Type Autonegotiation.
The functions in this package implement the behaviour specified in
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Copyright (c) 2011, Open Knowledge Foundation Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
...
...
vendor/github.com/prometheus/common/model/metric.go
View file @
5d7f1781
...
...
@@ -21,7 +21,6 @@ import (
)
var
(
separator
=
[]
byte
{
0
}
// MetricNameRE is a regular expression matching valid metric
// names. Note that the IsValidMetricName function performs the same
// check but faster than a match with this regular expression.
...
...
vendor/github.com/prometheus/procfs/MAINTAINERS.md
View file @
5d7f1781
*
Tobias Schmidt
<tobidt@gmail.com>
*
Tobias Schmidt
<tobidt@gmail.com>
@grobie
*
Johannes 'fish' Ziemke
<github@freigeist.org>
@discordianfish
vendor/github.com/prometheus/procfs/Makefile
View file @
5d7f1781
...
...
@@ -11,67 +11,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Ensure GOBIN is not set during build so that promu is installed to the correct path
un
export
GOBIN
GO
?=
go
GOFMT
?=
$(GO)
fmt
FIRST_GOPATH
:=
$(
firstword
$(
subst
:, ,
$(
shell
$(GO)
env
GOPATH
)))
STATICCHECK
:=
$(FIRST_GOPATH)
/bin/staticcheck
pkgs
=
$(
shell
$(GO)
list ./... |
grep
-v
/vendor/
)
PREFIX
?=
$(
shell
pwd
)
BIN_DIR
?=
$(
shell
pwd
)
ifdef
DEBUG
bindata_flags
=
-debug
endif
STATICCHECK_IGNORE
=
all
:
format staticcheck build test
style
:
@
echo
">> checking code style"
@
!
$(GOFMT)
-d
$(
shell
find
.
-path
./vendor
-prune
-o
-name
'*.go'
-print
)
|
grep
'^'
check_license
:
@
echo
">> checking license header"
@
./scripts/check_license.sh
test
:
fixtures/.unpacked sysfs/fixtures/.unpacked
@
echo
">> running all tests"
@
$(GO)
test
-race
$(
shell
$(GO)
list ./... |
grep
-v
/vendor/ |
grep
-v
examples
)
format
:
@
echo
">> formatting code"
@
$(GO)
fmt
$(pkgs)
vet
:
@
echo
">> vetting code"
@
$(GO)
vet
$(pkgs)
staticcheck
:
$(STATICCHECK)
@
echo
">> running staticcheck"
@
$(STATICCHECK)
-ignore
"
$(STATICCHECK_IGNORE)
"
$(pkgs)
include
Makefile.common
%/.unpacked
:
%.ttar
./ttar
-C
$(
dir
$*
)
-x
-f
$*
.ttar
touch
$@
update_fixtures
:
fixtures.ttar sysfs/fixtures.ttar
%fixtures.ttar
:
%/fixtures
rm
-v
$(
dir
$*
)
fixtures/.unpacked
./ttar
-C
$(
dir
$*
)
-c
-f
$*
fixtures.ttar fixtures/
$(FIRST_GOPATH)/bin/staticcheck
:
@
GOOS
=
GOARCH
=
$(GO)
get
-u
honnef.co/go/tools/cmd/staticcheck
update_fixtures
:
rm
-vf
fixtures/.unpacked
./ttar
-c
-f
fixtures.ttar fixtures/
.PHONY
:
all style check_license format test vet staticcheck
.PHONY
:
build
build
:
# Declaring the binaries at their default locations as PHONY targets is a hack
# to ensure the latest version is downloaded on every make execution.
# If this is not desired, copy/symlink these binaries to a different path and
# set the respective environment variables.
.PHONY
:
$(GOPATH)/bin/staticcheck
.PHONY
:
test
test
:
fixtures/.unpacked common-test
vendor/github.com/prometheus/procfs/Makefile.common
0 → 100644