Compare commits
126 Commits
Author | SHA1 | Date | |
---|---|---|---|
d4472e1ab2 | |||
6f6d362c20 | |||
dd71d9ec59 | |||
da9201efff | |||
fc9be7fb46 | |||
1dc55cc0c9 | |||
21494e0e7a | |||
0975e8fb4d | |||
8dfa97b54f | |||
439d5cf125 | |||
e02f291db2 | |||
4e64f3f994 | |||
c0b834b0b4 | |||
f937328147 | |||
|
883569bf14 | ||
e32c70a27d | |||
|
8c9abca56e | ||
09c9cbb39f | |||
|
1075d8cf42 | ||
92db4e4209 | |||
|
06ebcd2764 | ||
66878c406f | |||
|
0561824ca3 | ||
|
6210e2ad0c | ||
89c00bb59f | |||
|
8d20f74ec9 | ||
|
e0634128f1 | ||
|
873801833b | ||
160217d9a5 | |||
|
6053ceecc3 | ||
34e909dc98 | |||
|
ae51f8ff7c | ||
f561c77a0d | |||
|
aba9197d2b | ||
f2c3f3d5d1 | |||
|
a702bb558d | ||
aa685064bc | |||
|
7f5ce2e66c | ||
11f849b92d | |||
|
e0c8b29893 | ||
c57e4eedbd | |||
|
b8b9b8ae6b | ||
|
d9f6ca8fae | ||
5ca911c33a | |||
|
09205abdcf | ||
63ab0dbc88 | |||
|
8e21533a35 | ||
|
5c3028d217 | ||
997de86f0f | |||
43d28eca6f | |||
|
49fab99ef6 | ||
|
8f64a205a7 | ||
|
b629031cdc | ||
|
b1082245a6 | ||
|
6b11525d4a | ||
|
f0847578a4 | ||
a0ea7509f7 | |||
|
e30bd45b92 | ||
b6da2df6dc | |||
|
1c8a9d87e8 | ||
|
dbc53d520a | ||
|
ee1616c05b | ||
|
e6cd8bb731 | ||
|
4be3245371 | ||
da1ebc38ca | |||
|
14acb77ab8 | ||
|
9ef586a818 | ||
|
44a26918f9 | ||
95ae9cd371 | |||
|
7cc49c92cd | ||
5517b36e40 | |||
|
7ce39c2bcc | ||
cecd5801cc | |||
|
99063751e1 | ||
6dfd19692d | |||
|
7cc55694f9 | ||
e9bdb73e79 | |||
|
558e2b2360 | ||
d13f36d444 | |||
|
2f6780544e | ||
ce1eeb4af1 | |||
|
79626cb7fb | ||
9afed0bfb0 | |||
eac6b15775 | |||
85319f9bd0 | |||
e4f2c77510 | |||
b77f70aeb0 | |||
bae8886836 | |||
8ad0258828 | |||
d7a9e96561 | |||
4a8caabc52 | |||
5d50b02888 | |||
|
c793eeafda | ||
|
4bad2f0a5f | ||
|
1dac3b9598 | ||
|
c77ac5eed2 | ||
dc498edc1b | |||
326eceddc5 | |||
|
071a135a70 | ||
336b128033 | |||
4579965c49 | |||
944294f19f | |||
|
2a6371c797 | ||
|
629a3fee48 | ||
6dc3d858d6 | |||
|
e7797e2e46 | ||
1a03f7e25f | |||
50d21479fd | |||
2f8021fe00 | |||
0571f46d75 | |||
13843fbcf4 | |||
|
d4d0604412 | ||
fe897ee428 | |||
|
d142fc6e91 | ||
2d918e9f5a | |||
|
6d80445682 | ||
bb514b5dc2 | |||
|
b79261650a | ||
62c424c47f | |||
|
078a9c9391 | ||
45a8351d5e | |||
|
4eb66bfe99 | ||
54aee07622 | |||
|
357455f07d | ||
9b86861918 | |||
|
5fa2e1bef0 |
20
.github/workflows/autoapprove.yml
vendored
Normal file
20
.github/workflows/autoapprove.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name: "autoapprove"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [assigned, opened, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
autoapprove:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: approve
|
||||
uses: hmarr/auto-approve-action@v3
|
||||
if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]'
|
||||
id: approve
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
21
.github/workflows/automerge.yml
vendored
Normal file
21
.github/workflows/automerge.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
name: "automerge"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [assigned, opened, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
automerge:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.actor == 'vtolstov'
|
||||
steps:
|
||||
- name: merge
|
||||
id: merge
|
||||
run: gh pr merge --auto --merge "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{github.event.pull_request.html_url}}
|
||||
GITHUB_TOKEN: ${{secrets.TOKEN}}
|
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@ -3,19 +3,20 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- v3
|
||||
jobs:
|
||||
test:
|
||||
name: test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: setup
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.16
|
||||
go-version: 1.17
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
@ -31,9 +32,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
uses: golangci/golangci-lint-action@v3.4.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||
|
12
.github/workflows/codeql-analysis.yml
vendored
12
.github/workflows/codeql-analysis.yml
vendored
@ -43,14 +43,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: setup
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.16
|
||||
go-version: 1.17
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: init
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@ -61,7 +61,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@ -75,4 +75,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: analyze
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
14
.github/workflows/dependabot-automerge.yml
vendored
14
.github/workflows/dependabot-automerge.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: "prautomerge"
|
||||
name: "dependabot-automerge"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
@ -9,21 +9,17 @@ permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
dependabot:
|
||||
automerge:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||
if: github.actor == 'dependabot[bot]'
|
||||
steps:
|
||||
- name: metadata
|
||||
id: metadata
|
||||
uses: dependabot/fetch-metadata@v1.1.1
|
||||
uses: dependabot/fetch-metadata@v1.3.6
|
||||
with:
|
||||
github-token: "${{ secrets.TOKEN }}"
|
||||
- name: approve
|
||||
run: gh pr review --approve "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{github.event.pull_request.html_url}}
|
||||
GITHUB_TOKEN: ${{secrets.TOKEN}}
|
||||
- name: merge
|
||||
id: merge
|
||||
if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
|
||||
run: gh pr merge --auto --merge "$PR_URL"
|
||||
env:
|
||||
|
13
.github/workflows/pr.yml
vendored
13
.github/workflows/pr.yml
vendored
@ -3,19 +3,20 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- v3
|
||||
jobs:
|
||||
test:
|
||||
name: test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: setup
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.16
|
||||
go-version: 1.17
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
@ -31,9 +32,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
uses: golangci/golangci-lint-action@v3.4.0
|
||||
continue-on-error: true
|
||||
with:
|
||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||
|
93
counter.go
Normal file
93
counter.go
Normal file
@ -0,0 +1,93 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
)
|
||||
|
||||
type prometheusCounter struct {
|
||||
name string
|
||||
c *dto.Metric
|
||||
n float64
|
||||
}
|
||||
|
||||
func (c *prometheusCounter) Add(n int) {
|
||||
addFloat64(&(c.n), float64(n))
|
||||
}
|
||||
|
||||
func (c *prometheusCounter) Dec() {
|
||||
addFloat64(&(c.n), float64(-1))
|
||||
}
|
||||
|
||||
func (c *prometheusCounter) Inc() {
|
||||
addFloat64(&(c.n), float64(1))
|
||||
}
|
||||
|
||||
func (c *prometheusCounter) Get() uint64 {
|
||||
return uint64(getFloat64(&(c.n)))
|
||||
}
|
||||
|
||||
func (c *prometheusCounter) Set(n uint64) {
|
||||
setFloat64(&(c.n), math.Float64frombits(n))
|
||||
}
|
||||
|
||||
type prometheusFloatCounter struct {
|
||||
name string
|
||||
c *dto.Metric
|
||||
n float64
|
||||
}
|
||||
|
||||
func (c *prometheusFloatCounter) Add(n float64) {
|
||||
addFloat64(&(c.n), n)
|
||||
}
|
||||
|
||||
func (c *prometheusFloatCounter) Dec() {
|
||||
addFloat64(&(c.n), float64(-1))
|
||||
}
|
||||
|
||||
func (c *prometheusFloatCounter) Inc() {
|
||||
addFloat64(&(c.n), float64(1))
|
||||
}
|
||||
|
||||
func (c *prometheusFloatCounter) Get() float64 {
|
||||
return getFloat64(&(c.n))
|
||||
}
|
||||
|
||||
func (c *prometheusFloatCounter) Set(n float64) {
|
||||
setFloat64(&(c.n), n)
|
||||
}
|
||||
|
||||
func (c *prometheusFloatCounter) Sub(n float64) {
|
||||
addFloat64(&(c.n), -n)
|
||||
}
|
||||
|
||||
func setFloat64(_addr *float64, value float64) float64 {
|
||||
addr := (*uint64)(unsafe.Pointer(_addr))
|
||||
for {
|
||||
x := atomic.LoadUint64(addr)
|
||||
if atomic.CompareAndSwapUint64(addr, x, math.Float64bits(value)) {
|
||||
return value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addFloat64(_addr *float64, delta float64) float64 {
|
||||
addr := (*uint64)(unsafe.Pointer(_addr))
|
||||
for {
|
||||
x := atomic.LoadUint64(addr)
|
||||
y := math.Float64frombits(x) + delta
|
||||
if atomic.CompareAndSwapUint64(addr, x, math.Float64bits(y)) {
|
||||
return y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getFloat64(_addr *float64) float64 {
|
||||
addr := (*uint64)(unsafe.Pointer(_addr))
|
||||
x := atomic.LoadUint64(addr)
|
||||
y := math.Float64frombits(x)
|
||||
return y
|
||||
}
|
13
gauge.go
Normal file
13
gauge.go
Normal file
@ -0,0 +1,13 @@
|
||||
package prometheus
|
||||
|
||||
import dto "github.com/prometheus/client_model/go"
|
||||
|
||||
type prometheusGauge struct {
|
||||
name string
|
||||
c *dto.Metric
|
||||
n float64
|
||||
}
|
||||
|
||||
func (c *prometheusGauge) Get() float64 {
|
||||
return getFloat64(&(c.n))
|
||||
}
|
23
go.mod
23
go.mod
@ -1,10 +1,23 @@
|
||||
module go.unistack.org/micro-meter-prometheus/v3
|
||||
|
||||
go 1.16
|
||||
go 1.22.0
|
||||
|
||||
require (
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/prometheus/client_model v0.2.0
|
||||
github.com/prometheus/common v0.26.0
|
||||
go.unistack.org/micro/v3 v3.8.7
|
||||
github.com/prometheus/client_golang v1.20.4
|
||||
github.com/prometheus/client_model v0.6.1
|
||||
github.com/prometheus/common v0.59.1
|
||||
go.unistack.org/micro/v3 v3.10.91
|
||||
google.golang.org/protobuf v1.34.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
go.unistack.org/micro-proto/v3 v3.4.1 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
google.golang.org/grpc v1.58.2 // indirect
|
||||
)
|
||||
|
192
go.sum
192
go.sum
@ -1,156 +1,44 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=
|
||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=
|
||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/silas/dag v0.0.0-20210626123444-3804bac2d6d4/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
go.unistack.org/micro-proto/v3 v3.1.0 h1:q39FwjFiRZn+Ux/tt+d3bJTmDtsQQWa+3SLYVo1vLfA=
|
||||
go.unistack.org/micro-proto/v3 v3.1.0/go.mod h1:DpRhYCBXlmSJ/AAXTmntvlh7kQkYU6eFvlmYAx4BQS8=
|
||||
go.unistack.org/micro/v3 v3.8.7 h1:k1zOpJ3uS8MxdhK8annRsa5J/LW7MpqPjwYuekW61wE=
|
||||
go.unistack.org/micro/v3 v3.8.7/go.mod h1:KMMmOmbgo/D52/rCAbqeKbBsgEEbSKM69he54J3ZIuA=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
|
||||
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0=
|
||||
github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.unistack.org/micro-proto/v3 v3.4.1 h1:UTjLSRz2YZuaHk9iSlVqqsA50JQNAEK2ZFboGqtEa9Q=
|
||||
go.unistack.org/micro-proto/v3 v3.4.1/go.mod h1:okx/cnOhzuCX0ggl/vToatbCupi0O44diiiLLsZ93Zo=
|
||||
go.unistack.org/micro/v3 v3.10.91 h1:vuJY4tXwpqimwIkEJ3TozMYNVQQs+C5QMlQWPgSY/YM=
|
||||
go.unistack.org/micro/v3 v3.10.91/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg=
|
||||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
|
||||
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
|
||||
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
39
histogram.go
Normal file
39
histogram.go
Normal file
@ -0,0 +1,39 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
)
|
||||
|
||||
type prometheusHistogram struct {
|
||||
name string
|
||||
c *dto.Metric
|
||||
}
|
||||
|
||||
func (c prometheusHistogram) Reset() {
|
||||
}
|
||||
|
||||
func (c prometheusHistogram) Update(n float64) {
|
||||
atomic.AddUint64(c.c.Histogram.SampleCount, 1)
|
||||
addFloat64(c.c.Histogram.SampleSum, n)
|
||||
for _, b := range c.c.Histogram.Bucket {
|
||||
if n > *b.UpperBound {
|
||||
continue
|
||||
}
|
||||
atomic.AddUint64(b.CumulativeCount, 1)
|
||||
}
|
||||
}
|
||||
|
||||
func (c prometheusHistogram) UpdateDuration(n time.Time) {
|
||||
x := time.Since(n).Seconds()
|
||||
atomic.AddUint64(c.c.Histogram.SampleCount, 1)
|
||||
addFloat64(c.c.Histogram.SampleSum, x)
|
||||
for _, b := range c.c.Histogram.Bucket {
|
||||
if x > *b.UpperBound {
|
||||
continue
|
||||
}
|
||||
atomic.AddUint64(b.CumulativeCount, 1)
|
||||
}
|
||||
}
|
456
prometheus.go
456
prometheus.go
@ -3,7 +3,9 @@ package prometheus
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -11,192 +13,195 @@ import (
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
xpool "go.unistack.org/micro/v3/util/xpool"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
var _ meter.Meter = (*prometheusMeter)(nil)
|
||||
|
||||
type prometheusMeter struct {
|
||||
opts meter.Options
|
||||
set prometheus.Registerer
|
||||
counter map[string]prometheusCounter
|
||||
floatCounter map[string]prometheusFloatCounter
|
||||
gauge map[string]prometheusGauge
|
||||
histogram map[string]prometheusHistogram
|
||||
summary map[string]prometheusSummary
|
||||
sync.Mutex
|
||||
counter map[uint64]*prometheusCounter
|
||||
floatCounter map[uint64]*prometheusFloatCounter
|
||||
gauge map[uint64]*prometheusGauge
|
||||
histogram map[uint64]*prometheusHistogram
|
||||
summary map[uint64]*prometheusSummary
|
||||
mfPool xpool.Pool[*dto.MetricFamily]
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func NewMeter(opts ...meter.Option) meter.Meter {
|
||||
func NewMeter(opts ...meter.Option) *prometheusMeter {
|
||||
return &prometheusMeter{
|
||||
set: prometheus.DefaultRegisterer,
|
||||
set: prometheus.NewRegistry(), // prometheus.DefaultRegisterer,
|
||||
opts: meter.NewOptions(opts...),
|
||||
counter: make(map[string]prometheusCounter),
|
||||
floatCounter: make(map[string]prometheusFloatCounter),
|
||||
gauge: make(map[string]prometheusGauge),
|
||||
histogram: make(map[string]prometheusHistogram),
|
||||
summary: make(map[string]prometheusSummary),
|
||||
counter: make(map[uint64]*prometheusCounter),
|
||||
floatCounter: make(map[uint64]*prometheusFloatCounter),
|
||||
gauge: make(map[uint64]*prometheusGauge),
|
||||
histogram: make(map[uint64]*prometheusHistogram),
|
||||
summary: make(map[uint64]*prometheusSummary),
|
||||
mfPool: xpool.NewPool[*dto.MetricFamily](func() *dto.MetricFamily {
|
||||
return &dto.MetricFamily{}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) buildMetric(name string, labels ...string) string {
|
||||
if len(m.opts.MetricPrefix) > 0 {
|
||||
name = m.opts.MetricPrefix + name
|
||||
}
|
||||
|
||||
nl := len(m.opts.Labels) + len(labels)
|
||||
if nl == 0 {
|
||||
return name
|
||||
}
|
||||
|
||||
nlabels := make([]string, 0, nl)
|
||||
nlabels = append(nlabels, m.opts.Labels...)
|
||||
nlabels = append(nlabels, labels...)
|
||||
|
||||
if len(m.opts.LabelPrefix) == 0 {
|
||||
return meter.BuildName(name, nlabels...)
|
||||
}
|
||||
|
||||
for idx := 0; idx < nl; idx++ {
|
||||
nlabels[idx] = m.opts.LabelPrefix + nlabels[idx]
|
||||
idx++
|
||||
}
|
||||
return meter.BuildName(name, nlabels...)
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) buildName(name string) string {
|
||||
if len(m.opts.MetricPrefix) > 0 {
|
||||
name = m.opts.MetricPrefix + name
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) buildLabels(labels ...string) []string {
|
||||
nl := len(m.opts.Labels) + len(labels)
|
||||
if nl == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
nlabels := make([]string, 0, nl)
|
||||
nlabels = append(nlabels, m.opts.Labels...)
|
||||
nlabels = append(nlabels, labels...)
|
||||
|
||||
for idx := 0; idx < nl; idx++ {
|
||||
nlabels[idx] = m.opts.LabelPrefix + nlabels[idx]
|
||||
idx++
|
||||
}
|
||||
return nlabels
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) Name() string {
|
||||
return m.opts.Name
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) mapLabels(labels ...string) map[string]string {
|
||||
labels = m.buildLabels(labels...)
|
||||
elementMap := make(map[string]string, len(labels)/2)
|
||||
for idx := 0; idx < len(labels); idx++ {
|
||||
elementMap[labels[idx]] = labels[idx+1]
|
||||
idx++
|
||||
}
|
||||
return elementMap
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) Counter(name string, labels ...string) meter.Counter {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
nm := m.buildMetric(name, labels...)
|
||||
c, ok := m.counter[nm]
|
||||
clabels := meter.BuildLabels(append(m.opts.Labels, labels...)...)
|
||||
h := newHash(name, clabels)
|
||||
m.mu.Lock()
|
||||
c, ok := m.counter[h]
|
||||
// fmt.Printf("counter name %s hash %v labels %v\n", name, h, labels)
|
||||
m.mu.Unlock()
|
||||
if !ok {
|
||||
nc := prometheus.NewGauge(prometheus.GaugeOpts{Name: m.buildName(name), ConstLabels: m.mapLabels(labels...)})
|
||||
m.set.MustRegister(nc)
|
||||
c = prometheusCounter{c: nc}
|
||||
m.counter[nm] = c
|
||||
var n float64
|
||||
c = &prometheusCounter{
|
||||
name: name,
|
||||
c: &dto.Metric{
|
||||
Gauge: &dto.Gauge{Value: &n},
|
||||
Label: labelMetric(clabels),
|
||||
},
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.counter[h] = c
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) FloatCounter(name string, labels ...string) meter.FloatCounter {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
nm := m.buildMetric(name, labels...)
|
||||
c, ok := m.floatCounter[nm]
|
||||
clabels := meter.BuildLabels(append(m.opts.Labels, labels...)...)
|
||||
h := newHash(name, clabels)
|
||||
m.mu.Lock()
|
||||
c, ok := m.floatCounter[h]
|
||||
m.mu.Unlock()
|
||||
if !ok {
|
||||
nc := prometheus.NewGauge(prometheus.GaugeOpts{Name: m.buildName(name), ConstLabels: m.mapLabels(labels...)})
|
||||
m.set.MustRegister(nc)
|
||||
c = prometheusFloatCounter{c: nc}
|
||||
m.floatCounter[nm] = c
|
||||
var n float64
|
||||
c = &prometheusFloatCounter{
|
||||
name: name,
|
||||
c: &dto.Metric{
|
||||
Gauge: &dto.Gauge{Value: &n},
|
||||
Label: labelMetric(clabels),
|
||||
},
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.floatCounter[h] = c
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) Gauge(name string, fn func() float64, labels ...string) meter.Gauge {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
nm := m.buildMetric(name, labels...)
|
||||
c, ok := m.gauge[nm]
|
||||
clabels := meter.BuildLabels(append(m.opts.Labels, labels...)...)
|
||||
h := newHash(name, clabels)
|
||||
m.mu.Lock()
|
||||
c, ok := m.gauge[h]
|
||||
m.mu.Unlock()
|
||||
if !ok {
|
||||
nc := prometheus.NewGauge(prometheus.GaugeOpts{Name: m.buildName(name), ConstLabels: m.mapLabels(labels...)})
|
||||
m.set.MustRegister(nc)
|
||||
c = prometheusGauge{c: nc}
|
||||
m.gauge[nm] = c
|
||||
var n float64
|
||||
c = &prometheusGauge{
|
||||
name: name,
|
||||
c: &dto.Metric{
|
||||
Gauge: &dto.Gauge{Value: &n},
|
||||
Label: labelMetric(clabels),
|
||||
},
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.gauge[h] = c
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) Histogram(name string, labels ...string) meter.Histogram {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
nm := m.buildMetric(name, labels...)
|
||||
c, ok := m.histogram[nm]
|
||||
clabels := meter.BuildLabels(append(m.opts.Labels, labels...)...)
|
||||
h := newHash(name, clabels)
|
||||
m.mu.Lock()
|
||||
c, ok := m.histogram[h]
|
||||
m.mu.Unlock()
|
||||
if !ok {
|
||||
nc := prometheus.NewHistogram(prometheus.HistogramOpts{Name: m.buildName(name), ConstLabels: m.mapLabels(labels...)})
|
||||
m.set.MustRegister(nc)
|
||||
c = prometheusHistogram{c: nc}
|
||||
m.histogram[nm] = c
|
||||
var n uint64
|
||||
var s float64
|
||||
buckets := make([]float64, len(prometheus.DefBuckets))
|
||||
copy(buckets, prometheus.DefBuckets)
|
||||
mdto := &dto.Metric{
|
||||
Histogram: &dto.Histogram{
|
||||
SampleCount: &n,
|
||||
SampleSum: &s,
|
||||
CreatedTimestamp: timestamppb.Now(),
|
||||
Bucket: make([]*dto.Bucket, len(buckets)),
|
||||
},
|
||||
Label: labelMetric(clabels),
|
||||
}
|
||||
for idx, b := range buckets {
|
||||
var cc uint64
|
||||
mdto.Histogram.Bucket[idx] = &dto.Bucket{CumulativeCount: &cc, UpperBound: &b}
|
||||
}
|
||||
c = &prometheusHistogram{
|
||||
name: name,
|
||||
c: mdto,
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.histogram[h] = c
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) Summary(name string, labels ...string) meter.Summary {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
nm := m.buildMetric(name, labels...)
|
||||
c, ok := m.summary[nm]
|
||||
clabels := meter.BuildLabels(append(m.opts.Labels, labels...)...)
|
||||
h := newHash(name, clabels)
|
||||
m.mu.Lock()
|
||||
c, ok := m.summary[h]
|
||||
m.mu.Unlock()
|
||||
if !ok {
|
||||
nc := prometheus.NewSummary(prometheus.SummaryOpts{Name: m.buildName(name), ConstLabels: m.mapLabels(labels...)})
|
||||
m.set.MustRegister(nc)
|
||||
c = prometheusSummary{c: nc}
|
||||
m.summary[nm] = c
|
||||
var n uint64
|
||||
var s float64
|
||||
c = &prometheusSummary{
|
||||
name: name,
|
||||
c: &dto.Metric{
|
||||
Summary: &dto.Summary{
|
||||
SampleCount: &n,
|
||||
SampleSum: &s,
|
||||
CreatedTimestamp: timestamppb.Now(),
|
||||
},
|
||||
Label: labelMetric(clabels),
|
||||
},
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.summary[h] = c
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (m *prometheusMeter) SummaryExt(name string, window time.Duration, quantiles []float64, labels ...string) meter.Summary {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
nm := m.buildMetric(name, labels...)
|
||||
c, ok := m.summary[nm]
|
||||
clabels := meter.BuildLabels(append(m.opts.Labels, labels...)...)
|
||||
h := newHash(name, clabels)
|
||||
m.mu.Lock()
|
||||
c, ok := m.summary[h]
|
||||
m.mu.Lock()
|
||||
if !ok {
|
||||
nc := prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Name: m.buildName(name),
|
||||
ConstLabels: m.mapLabels(labels...),
|
||||
MaxAge: window,
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
})
|
||||
m.set.MustRegister(nc)
|
||||
c = prometheusSummary{c: nc}
|
||||
m.summary[nm] = c
|
||||
var n uint64
|
||||
var s float64
|
||||
c = &prometheusSummary{
|
||||
name: name,
|
||||
c: &dto.Metric{
|
||||
Summary: &dto.Summary{
|
||||
SampleCount: &n,
|
||||
SampleSum: &s,
|
||||
},
|
||||
Label: labelMetric(clabels),
|
||||
},
|
||||
}
|
||||
m.mu.Lock()
|
||||
m.summary[h] = c
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
@ -205,6 +210,13 @@ func (m *prometheusMeter) Init(opts ...meter.Option) error {
|
||||
o(&m.opts)
|
||||
}
|
||||
|
||||
if m.opts.WriteProcessMetrics || m.opts.WriteFDMetrics {
|
||||
pc := collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})
|
||||
_ = m.set.Register(pc)
|
||||
gc := collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")}))
|
||||
_ = m.set.Register(gc)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -214,11 +226,6 @@ func (m *prometheusMeter) Write(w io.Writer, opts ...meter.Option) error {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
if options.WriteProcessMetrics || options.WriteFDMetrics {
|
||||
c := collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})
|
||||
_ = m.set.Register(c)
|
||||
}
|
||||
|
||||
g, ok := m.set.(prometheus.Gatherer)
|
||||
if !ok {
|
||||
return fmt.Errorf("set type %T not prometheus.Gatherer", m.set)
|
||||
@ -229,9 +236,66 @@ func (m *prometheusMeter) Write(w io.Writer, opts ...meter.Option) error {
|
||||
return err
|
||||
}
|
||||
|
||||
enc := expfmt.NewEncoder(w, expfmt.FmtText)
|
||||
enc := expfmt.NewEncoder(w, expfmt.NewFormat(expfmt.TypeTextPlain))
|
||||
|
||||
m.mu.Lock()
|
||||
|
||||
for _, mc := range m.counter {
|
||||
mf := m.mfPool.Get()
|
||||
mf.Name = &mc.name
|
||||
mf.Type = dto.MetricType_GAUGE.Enum()
|
||||
n := getFloat64(&(mc.n))
|
||||
mc.c.Gauge.Value = &n
|
||||
mf.Metric = append(mf.Metric, mc.c)
|
||||
mfs = append(mfs, mf)
|
||||
}
|
||||
|
||||
for _, mc := range m.floatCounter {
|
||||
mf := m.mfPool.Get()
|
||||
mf.Name = &mc.name
|
||||
mf.Type = dto.MetricType_GAUGE.Enum()
|
||||
n := getFloat64(&(mc.n))
|
||||
mc.c.Gauge.Value = &n
|
||||
mf.Metric = append(mf.Metric, mc.c)
|
||||
mfs = append(mfs, mf)
|
||||
}
|
||||
|
||||
for _, mc := range m.gauge {
|
||||
mf := m.mfPool.Get()
|
||||
mf.Name = &mc.name
|
||||
mf.Type = dto.MetricType_GAUGE.Enum()
|
||||
n := getFloat64(&(mc.n))
|
||||
mc.c.Gauge.Value = &n
|
||||
mf.Metric = append(mf.Metric, mc.c)
|
||||
mfs = append(mfs, mf)
|
||||
}
|
||||
|
||||
for _, c := range m.histogram {
|
||||
mf := m.mfPool.Get()
|
||||
mf.Name = &c.name
|
||||
mf.Type = dto.MetricType_HISTOGRAM.Enum()
|
||||
mf.Metric = append(mf.Metric, c.c)
|
||||
mfs = append(mfs, mf)
|
||||
}
|
||||
|
||||
for _, mc := range m.summary {
|
||||
mf := m.mfPool.Get()
|
||||
mf.Name = &mc.name
|
||||
mf.Type = dto.MetricType_SUMMARY.Enum()
|
||||
sc := atomic.LoadUint64(&(mc.sampleCount))
|
||||
mc.c.Summary.SampleCount = &sc
|
||||
ss := getFloat64(&(mc.SampleSum))
|
||||
mc.c.Summary.SampleSum = &ss
|
||||
mf.Metric = append(mf.Metric, mc.c)
|
||||
mfs = append(mfs, mf)
|
||||
}
|
||||
|
||||
m.mu.Unlock()
|
||||
|
||||
for _, mf := range mfs {
|
||||
_ = enc.Encode(mf)
|
||||
mf.Reset()
|
||||
m.mfPool.Put(mf)
|
||||
}
|
||||
|
||||
if closer, ok := enc.(io.Closer); ok {
|
||||
@ -250,6 +314,7 @@ func (m *prometheusMeter) Clone(opts ...meter.Option) meter.Meter {
|
||||
return &prometheusMeter{
|
||||
set: m.set,
|
||||
opts: options,
|
||||
floatCounter: m.floatCounter,
|
||||
counter: m.counter,
|
||||
gauge: m.gauge,
|
||||
histogram: m.histogram,
|
||||
@ -274,93 +339,30 @@ func (m *prometheusMeter) Set(opts ...meter.Option) meter.Meter {
|
||||
return nm
|
||||
}
|
||||
|
||||
type prometheusCounter struct {
|
||||
c prometheus.Gauge
|
||||
}
|
||||
|
||||
func (c prometheusCounter) Add(n int) {
|
||||
c.c.Add(float64(n))
|
||||
}
|
||||
|
||||
func (c prometheusCounter) Dec() {
|
||||
c.c.Dec()
|
||||
}
|
||||
|
||||
func (c prometheusCounter) Inc() {
|
||||
c.c.Inc()
|
||||
}
|
||||
|
||||
func (c prometheusCounter) Get() uint64 {
|
||||
m := &dto.Metric{}
|
||||
if err := c.c.Write(m); err != nil {
|
||||
return 0
|
||||
func labelMetric(labels []string) []*dto.LabelPair {
|
||||
nl := make([]string, len(labels))
|
||||
copy(nl, labels)
|
||||
dtoLabels := make([]*dto.LabelPair, 0, len(nl)/2)
|
||||
for idx := 0; idx < len(nl); idx += 2 {
|
||||
dtoLabels = append(dtoLabels, &dto.LabelPair{
|
||||
Name: &(nl[idx]),
|
||||
Value: &(nl[idx+1]),
|
||||
})
|
||||
}
|
||||
return uint64(m.GetGauge().GetValue())
|
||||
return dtoLabels
|
||||
}
|
||||
|
||||
func (c prometheusCounter) Set(n uint64) {
|
||||
c.c.Set(float64(n))
|
||||
}
|
||||
|
||||
type prometheusFloatCounter struct {
|
||||
c prometheus.Gauge
|
||||
}
|
||||
|
||||
func (c prometheusFloatCounter) Add(n float64) {
|
||||
c.c.Add(n)
|
||||
}
|
||||
|
||||
func (c prometheusFloatCounter) Get() float64 {
|
||||
m := &dto.Metric{}
|
||||
if err := c.c.Write(m); err != nil {
|
||||
return 0
|
||||
func newHash(n string, l []string) uint64 {
|
||||
h := uint64(14695981039346656037)
|
||||
for i := 0; i < len(n); i++ {
|
||||
h ^= uint64(n[i])
|
||||
h *= 1099511628211
|
||||
}
|
||||
return m.GetGauge().GetValue()
|
||||
}
|
||||
|
||||
func (c prometheusFloatCounter) Set(n float64) {
|
||||
c.c.Set(n)
|
||||
}
|
||||
|
||||
func (c prometheusFloatCounter) Sub(n float64) {
|
||||
c.c.Add(-n)
|
||||
}
|
||||
|
||||
type prometheusGauge struct {
|
||||
c prometheus.Gauge
|
||||
}
|
||||
|
||||
func (c prometheusGauge) Get() float64 {
|
||||
m := &dto.Metric{}
|
||||
if err := c.c.Write(m); err != nil {
|
||||
return 0
|
||||
for _, s := range l {
|
||||
for i := 0; i < len(s); i++ {
|
||||
h ^= uint64(s[i])
|
||||
h *= 1099511628211
|
||||
}
|
||||
return float64(m.GetGauge().GetValue())
|
||||
}
|
||||
|
||||
type prometheusHistogram struct {
|
||||
c prometheus.Histogram
|
||||
}
|
||||
|
||||
func (c prometheusHistogram) Reset() {
|
||||
}
|
||||
|
||||
func (c prometheusHistogram) Update(n float64) {
|
||||
c.c.Observe(n)
|
||||
}
|
||||
|
||||
func (c prometheusHistogram) UpdateDuration(n time.Time) {
|
||||
c.c.Observe(time.Since(n).Seconds())
|
||||
}
|
||||
|
||||
type prometheusSummary struct {
|
||||
c prometheus.Summary
|
||||
}
|
||||
|
||||
func (c prometheusSummary) Update(n float64) {
|
||||
c.c.Observe(n)
|
||||
}
|
||||
|
||||
func (c prometheusSummary) UpdateDuration(n time.Time) {
|
||||
c.c.Observe(time.Since(n).Seconds())
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
@ -3,40 +3,143 @@ package prometheus
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
"go.unistack.org/micro/v3/meter/wrapper"
|
||||
)
|
||||
|
||||
func TestBuildName(t *testing.T) {
|
||||
func TestHash(t *testing.T) {
|
||||
m := NewMeter() // meter.Labels("test_key", "test_val"))
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
|
||||
for i := 0; i < 100000; i++ {
|
||||
go func() {
|
||||
m.Counter("micro_server_request_total", "code", "16",
|
||||
"endpoint", "/clientprofile.ClientProfileService/GetClientProfile",
|
||||
"status", "failure").Inc()
|
||||
m.Counter("micro_server_request_total", "code", "16",
|
||||
"endpoint", "/clientproduct.ClientProductService/GetDepositProducts",
|
||||
"status", "failure").Inc()
|
||||
m.Counter("micro_server_request_total", "code", "16",
|
||||
"endpoint", "/operationsinfo.OperationsInfoService/GetOperations",
|
||||
"status", "failure").Inc()
|
||||
}()
|
||||
}
|
||||
_ = m.Write(buf)
|
||||
t.Logf("h1: %s\n", buf.Bytes())
|
||||
}
|
||||
|
||||
func TestHistogram(t *testing.T) {
|
||||
m := NewMeter()
|
||||
im := m.(*prometheusMeter)
|
||||
check := `micro_foo{micro_aaa="b",micro_bar="baz",micro_ccc="d"}`
|
||||
name := im.buildMetric("foo", "bar", "baz", "aaa", "b", "ccc", "d")
|
||||
if name != check {
|
||||
t.Fatalf("metric name error: %s != %s", name, check)
|
||||
name := "test"
|
||||
m.Histogram(name, "endpoint").Update(1)
|
||||
m.Histogram(name, "endpoint").Update(1)
|
||||
m.Histogram(name, "endpoint").Update(5)
|
||||
m.Histogram(name, "endpoint").Update(10)
|
||||
m.Histogram(name, "endpoint").Update(10)
|
||||
m.Histogram(name, "endpoint").Update(30)
|
||||
mbuf := bytes.NewBuffer(nil)
|
||||
_ = m.Write(mbuf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
|
||||
|
||||
/*
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_server_sum{endpoint="ep1",path="/path1"} 20`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
|
||||
cnt := m.Counter("counter", "key", "val")
|
||||
cnt.Inc()
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_server_count{endpoint="ep1",path="/path1"} 2`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
*/
|
||||
p := prometheus.NewHistogram(prometheus.HistogramOpts{Name: name})
|
||||
p.Observe(1)
|
||||
p.Observe(1)
|
||||
p.Observe(5)
|
||||
p.Observe(10)
|
||||
p.Observe(10)
|
||||
p.Observe(30)
|
||||
mdto := &dto.Metric{}
|
||||
p.Write(mdto)
|
||||
pbuf := bytes.NewBuffer(nil)
|
||||
enc := expfmt.NewEncoder(pbuf, expfmt.NewFormat(expfmt.TypeTextPlain))
|
||||
mf := &dto.MetricFamily{Name: &name, Type: dto.MetricType_HISTOGRAM.Enum(), Metric: []*dto.Metric{mdto}}
|
||||
_ = enc.Encode(mf)
|
||||
|
||||
if !bytes.Equal(mbuf.Bytes(), pbuf.Bytes()) {
|
||||
fmt.Printf("m\n%s\n", mbuf.Bytes())
|
||||
fmt.Printf("m\n%s\n", pbuf.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSummary(t *testing.T) {
|
||||
t.Skip()
|
||||
name := "micro_server"
|
||||
m := NewMeter()
|
||||
m.Summary("micro_server").Update(1)
|
||||
m.Summary("micro_server").Update(1)
|
||||
m.Summary("micro_server").Update(5)
|
||||
m.Summary("micro_server").Update(10)
|
||||
m.Summary("micro_server").Update(10)
|
||||
m.Summary("micro_server").Update(30)
|
||||
mbuf := bytes.NewBuffer(nil)
|
||||
_ = m.Write(mbuf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
|
||||
|
||||
if !bytes.Contains(mbuf.Bytes(), []byte(`micro_server_sum 57`)) {
|
||||
t.Fatalf("invalid metrics output: %s", mbuf.Bytes())
|
||||
}
|
||||
|
||||
if !bytes.Contains(mbuf.Bytes(), []byte(`micro_server_count 6`)) {
|
||||
t.Fatalf("invalid metrics output: %s", mbuf.Bytes())
|
||||
}
|
||||
|
||||
objectives := make(map[float64]float64)
|
||||
for _, c := range meter.DefaultSummaryQuantiles {
|
||||
objectives[c] = c
|
||||
}
|
||||
p := prometheus.NewSummary(prometheus.SummaryOpts{Name: name, Objectives: objectives, MaxAge: meter.DefaultSummaryWindow})
|
||||
p.Observe(1)
|
||||
p.Observe(1)
|
||||
p.Observe(5)
|
||||
p.Observe(10)
|
||||
p.Observe(10)
|
||||
p.Observe(30)
|
||||
mdto := &dto.Metric{}
|
||||
_ = p.Write(mdto)
|
||||
pbuf := bytes.NewBuffer(nil)
|
||||
enc := expfmt.NewEncoder(pbuf, expfmt.NewFormat(expfmt.TypeTextPlain))
|
||||
mf := &dto.MetricFamily{Name: &name, Type: dto.MetricType_SUMMARY.Enum(), Metric: []*dto.Metric{mdto}}
|
||||
_ = enc.Encode(mf)
|
||||
|
||||
if !bytes.Equal(mbuf.Bytes(), pbuf.Bytes()) {
|
||||
fmt.Printf("m\n%s\n", mbuf.Bytes())
|
||||
fmt.Printf("m\n%s\n", pbuf.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
func TestStd(t *testing.T) {
|
||||
m := NewMeter(meter.WriteProcessMetrics(true), meter.WriteFDMetrics(true))
|
||||
if err := m.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
buf := bytes.NewBuffer(nil)
|
||||
_ = m.Write(buf)
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`go_goroutine`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrapper(t *testing.T) {
|
||||
m := NewMeter() // meter.Labels("test_key", "test_val"))
|
||||
|
||||
w := wrapper.NewClientWrapper(
|
||||
wrapper.ServiceName("svc1"),
|
||||
wrapper.ServiceVersion("0.0.1"),
|
||||
wrapper.ServiceID("12345"),
|
||||
wrapper.Meter(m),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
c := client.NewClient(client.Wrap(w))
|
||||
c := client.NewClient(client.Meter(m))
|
||||
if err := c.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -46,7 +149,28 @@ func TestWrapper(t *testing.T) {
|
||||
_, _ = rsp, err
|
||||
buf := bytes.NewBuffer(nil)
|
||||
_ = m.Write(buf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_client_request_inflight{micro_endpoint="svc2.Service.Method"} 0`)) {
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_client_request_inflight{endpoint="Service.Method"} 0`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultiple(t *testing.T) {
|
||||
m := NewMeter() // meter.Labels("test_key", "test_val"))
|
||||
|
||||
m.Counter("micro_server", "endpoint", "ep1", "path", "/path1").Inc()
|
||||
m.Counter("micro_server", "endpoint", "ep1", "path", "/path1").Inc()
|
||||
|
||||
m.Counter("micro_server", "endpoint", "ep2", "path", "/path2").Inc()
|
||||
m.Counter("micro_server", "endpoint", "ep2", "path", "/path2").Inc()
|
||||
|
||||
m.Counter("micro_server", "endpoint", "ep3", "path", "/path3", "status", "success").Inc()
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
_ = m.Write(buf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_server{endpoint="ep1",path="/path1"} 2`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_server{endpoint="ep3",path="/path3",status="success"} 1`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
}
|
||||
|
26
summary.go
Normal file
26
summary.go
Normal file
@ -0,0 +1,26 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
)
|
||||
|
||||
type prometheusSummary struct {
|
||||
name string
|
||||
c *dto.Metric
|
||||
sampleCount uint64
|
||||
SampleSum float64
|
||||
}
|
||||
|
||||
func (c *prometheusSummary) Update(n float64) {
|
||||
atomic.AddUint64(&(c.sampleCount), 1)
|
||||
addFloat64(&(c.SampleSum), n)
|
||||
}
|
||||
|
||||
func (c *prometheusSummary) UpdateDuration(t time.Time) {
|
||||
n := time.Since(t).Seconds()
|
||||
atomic.AddUint64(&(c.sampleCount), 1)
|
||||
addFloat64(&(c.SampleSum), n)
|
||||
}
|
Loading…
Reference in New Issue
Block a user