Skip to content

Commit 7aff297

Browse files
committed
update client to promauto
Signed-off-by: SagiROosto <sagi.rosenthal@oosto.com>
1 parent 4d127c5 commit 7aff297

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
command: |
2424
cat \<< EOF > prometheus.yml
2525
global:
26-
scrape_interval: 10s
26+
scrape_interval: 1s
2727
scrape_configs:
2828
- job_name: pushprox
2929
proxy_url: http://127.0.0.1:8080

client/client.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,30 @@ import (
2929
"github.com/cenkalti/backoff/v4"
3030
"github.com/prometheus-community/pushprox/util"
3131
"github.com/prometheus/client_golang/prometheus"
32+
"github.com/prometheus/client_golang/prometheus/promauto"
3233
)
3334

3435
var (
35-
scrapeErrorCounter = prometheus.NewCounter(
36+
scrapeErrorCounter = promauto.NewCounter(
3637
prometheus.CounterOpts{
3738
Name: "pushprox_client_scrape_errors_total",
3839
Help: "Number of scrape errors",
3940
},
4041
)
41-
pushErrorCounter = prometheus.NewCounter(
42+
pushErrorCounter = promauto.NewCounter(
4243
prometheus.CounterOpts{
4344
Name: "pushprox_client_push_errors_total",
4445
Help: "Number of push errors",
4546
},
4647
)
47-
pollErrorCounter = prometheus.NewCounter(
48+
pollErrorCounter = promauto.NewCounter(
4849
prometheus.CounterOpts{
4950
Name: "pushprox_client_poll_errors_total",
5051
Help: "Number of poll errors",
5152
},
5253
)
5354
)
5455

55-
func init() {
56-
prometheus.MustRegister(pushErrorCounter, pollErrorCounter, scrapeErrorCounter)
57-
}
58-
5956
func DefaultBackoff() backoff.BackOff {
6057
b := backoff.NewExponentialBackOff()
6158
b.InitialInterval = 1 * time.Second

end-to-end-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ while ! curl -s -f -L http://localhost:8080/clients; do
2929
sleep 2
3030
done
3131

32-
./pushprox-client --log.level=debug --proxy-url=http://localhost:8080 --fqdn $(hostname) &
32+
./pushprox-client --log.level=debug --proxy-url=http://localhost:8080 &
3333
echo $! > "${tmpdir}/client.pid"
3434
while [ "$(curl -s -L 'http://localhost:8080/clients' | jq 'length')" != '1' ] ; do
3535
echo 'Waiting for client'

0 commit comments

Comments
 (0)