Skip to content

Commit 73cc86f

Browse files
authored
chore!: adopt log/slog, drop go-kit/log (#1311)
* chore!: adopt log/slog, drop go-kit/log The bulk of this change set was automated by the following script which is being used to aid in converting the various exporters/projects to use slog: https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434 Other changes included: - upgrade go in ci to 1.23 - update client_golang, common, exporter-toolkit Signed-off-by: TJ Hoplock <[email protected]> * build: don't specify toolchain in go.mod Address PR feedback, not necessary. Can always be re-added. Signed-off-by: TJ Hoplock <[email protected]> --------- Signed-off-by: TJ Hoplock <[email protected]>
1 parent 079f253 commit 73cc86f

21 files changed

+400
-337
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ executors:
55
# Whenever the Go version is updated here, .promu.yml should also be updated.
66
golang:
77
docker:
8-
- image: cimg/go:1.22
8+
- image: cimg/go:1.23
99
jobs:
1010
test:
1111
executor: golang
@@ -22,7 +22,7 @@ jobs:
2222
working_directory: /home/circleci/.go_workspace/src/github.com/prometheus/blackbox_exporter
2323
# Whenever the Go version is updated here, .promu.yml should also be updated.
2424
environment:
25-
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.22-base
25+
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.23-base
2626
steps:
2727
- checkout
2828
- run:

.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ linters:
44
enable:
55
- misspell
66
- staticcheck
7+
- sloglint

.promu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
go:
22
# Whenever the Go version is updated here, .circle/config.yml should also be updated.
3-
version: 1.22
3+
version: 1.23
44
repository:
55
path: github.com/prometheus/blackbox_exporter
66
build:

config/config.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package config
1616
import (
1717
"errors"
1818
"fmt"
19+
"log/slog"
1920
"math"
2021
"net/textproto"
2122
"os"
@@ -30,8 +31,6 @@ import (
3031
yaml "gopkg.in/yaml.v3"
3132

3233
"github.com/alecthomas/units"
33-
"github.com/go-kit/log"
34-
"github.com/go-kit/log/level"
3534
"github.com/miekg/dns"
3635
"github.com/prometheus/client_golang/prometheus"
3736
"github.com/prometheus/client_golang/prometheus/promauto"
@@ -104,7 +103,7 @@ func NewSafeConfig(reg prometheus.Registerer) *SafeConfig {
104103
return &SafeConfig{C: &Config{}, configReloadSuccess: configReloadSuccess, configReloadSeconds: configReloadSeconds}
105104
}
106105

107-
func (sc *SafeConfig) ReloadConfig(confFile string, logger log.Logger) (err error) {
106+
func (sc *SafeConfig) ReloadConfig(confFile string, logger *slog.Logger) (err error) {
108107
var c = &Config{}
109108
defer func() {
110109
if err != nil {
@@ -133,7 +132,7 @@ func (sc *SafeConfig) ReloadConfig(confFile string, logger log.Logger) (err erro
133132
module.HTTP.NoFollowRedirects = nil
134133
c.Modules[name] = module
135134
if logger != nil {
136-
level.Warn(logger).Log("msg", "no_follow_redirects is deprecated and will be removed in the next release. It is replaced by follow_redirects.", "module", name)
135+
logger.Warn("no_follow_redirects is deprecated and will be removed in the next release. It is replaced by follow_redirects.", "module", name)
137136
}
138137
}
139138
}

go.mod

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
module github.com/prometheus/blackbox_exporter
22

3-
go 1.21
3+
go 1.22
44

55
require (
66
github.com/alecthomas/kingpin/v2 v2.4.0
77
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9
88
github.com/andybalholm/brotli v1.1.0
9-
github.com/go-kit/log v0.2.1
109
github.com/miekg/dns v1.1.62
11-
github.com/prometheus/client_golang v1.20.4
10+
github.com/prometheus/client_golang v1.20.5
1211
github.com/prometheus/client_model v0.6.1
13-
github.com/prometheus/common v0.57.0
14-
github.com/prometheus/exporter-toolkit v0.11.0
15-
golang.org/x/net v0.28.0
12+
github.com/prometheus/common v0.60.1
13+
github.com/prometheus/exporter-toolkit v0.13.0
14+
golang.org/x/net v0.29.0
1615
google.golang.org/grpc v1.67.0
1716
gopkg.in/yaml.v2 v2.4.0
1817
gopkg.in/yaml.v3 v3.0.1
@@ -22,19 +21,20 @@ require (
2221
github.com/beorn7/perks v1.0.1 // indirect
2322
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2423
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
25-
github.com/go-logfmt/logfmt v0.5.1 // indirect
2624
github.com/jpillora/backoff v1.0.0 // indirect
2725
github.com/klauspost/compress v1.17.9 // indirect
26+
github.com/mdlayher/socket v0.4.1 // indirect
27+
github.com/mdlayher/vsock v1.2.1 // indirect
2828
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
2929
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
3030
github.com/prometheus/procfs v0.15.1 // indirect
3131
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
32-
golang.org/x/crypto v0.26.0 // indirect
32+
golang.org/x/crypto v0.27.0 // indirect
3333
golang.org/x/mod v0.18.0 // indirect
34-
golang.org/x/oauth2 v0.22.0 // indirect
34+
golang.org/x/oauth2 v0.23.0 // indirect
3535
golang.org/x/sync v0.8.0 // indirect
36-
golang.org/x/sys v0.24.0 // indirect
37-
golang.org/x/text v0.17.0 // indirect
36+
golang.org/x/sys v0.25.0 // indirect
37+
golang.org/x/text v0.18.0 // indirect
3838
golang.org/x/tools v0.22.0 // indirect
3939
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
4040
google.golang.org/protobuf v1.34.2 // indirect

go.sum

+20-20
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
1313
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1414
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1515
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
16-
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
17-
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
18-
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
19-
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
2016
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
2117
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
2218
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@@ -30,6 +26,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3026
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
3127
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
3228
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
29+
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
30+
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
31+
github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ=
32+
github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE=
3333
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
3434
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
3535
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
@@ -38,14 +38,14 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
3838
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
3939
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4040
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
41-
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
42-
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
41+
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
42+
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
4343
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
4444
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
45-
github.com/prometheus/common v0.57.0 h1:Ro/rKjwdq9mZn1K5QPctzh+MA4Lp0BuYk5ZZEVhoNcY=
46-
github.com/prometheus/common v0.57.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
47-
github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g=
48-
github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q=
45+
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
46+
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
47+
github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c=
48+
github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0=
4949
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
5050
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
5151
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
@@ -56,20 +56,20 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
5656
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
5757
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
5858
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
59-
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
60-
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
59+
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
60+
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
6161
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
6262
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
63-
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
64-
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
65-
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
66-
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
63+
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
64+
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
65+
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
66+
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
6767
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
6868
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
69-
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
70-
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
71-
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
72-
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
69+
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
70+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
71+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
72+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
7373
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
7474
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
7575
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=

main.go

+26-27
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ import (
2929
"syscall"
3030

3131
"github.com/alecthomas/kingpin/v2"
32-
"github.com/go-kit/log/level"
3332
"github.com/prometheus/client_golang/prometheus"
3433
versioncollector "github.com/prometheus/client_golang/prometheus/collectors/version"
3534
"github.com/prometheus/client_golang/prometheus/promauto"
3635
"github.com/prometheus/client_golang/prometheus/promhttp"
37-
"github.com/prometheus/common/promlog"
38-
"github.com/prometheus/common/promlog/flag"
36+
"github.com/prometheus/common/promslog"
37+
"github.com/prometheus/common/promslog/flag"
3938
"github.com/prometheus/common/version"
4039
"github.com/prometheus/exporter-toolkit/web"
4140
webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag"
@@ -51,7 +50,7 @@ var (
5150
configFile = kingpin.Flag("config.file", "Blackbox exporter configuration file.").Default("blackbox.yml").String()
5251
timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64()
5352
configCheck = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool()
54-
logLevelProber = kingpin.Flag("log.prober", "Log level from probe requests. One of: [debug, info, warn, error, none]").Default("none").String()
53+
logLevelProber = kingpin.Flag("log.prober", "Log level from probe requests. One of: [debug, info, warn, error]").Default("info").String()
5554
historyLimit = kingpin.Flag("history.limit", "The maximum amount of items to keep in the history.").Default("100").Uint()
5655
externalURL = kingpin.Flag("web.external-url", "The URL under which Blackbox exporter is externally reachable (for example, if Blackbox exporter is served via a reverse proxy). Used for generating relative and absolute links back to Blackbox exporter itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Blackbox exporter. If omitted, relevant URL components will be derived automatically.").PlaceHolder("<url>").String()
5756
routePrefix = kingpin.Flag("web.route-prefix", "Prefix for the internal routes of web endpoints. Defaults to path of --web.external-url.").PlaceHolder("<path>").String()
@@ -73,46 +72,46 @@ func main() {
7372

7473
func run() int {
7574
kingpin.CommandLine.UsageWriter(os.Stdout)
76-
promlogConfig := &promlog.Config{}
77-
flag.AddFlags(kingpin.CommandLine, promlogConfig)
75+
promslogConfig := &promslog.Config{}
76+
flag.AddFlags(kingpin.CommandLine, promslogConfig)
7877
kingpin.Version(version.Print("blackbox_exporter"))
7978
kingpin.HelpFlag.Short('h')
8079
kingpin.Parse()
81-
logger := promlog.New(promlogConfig)
80+
logger := promslog.New(promslogConfig)
8281
rh := &prober.ResultHistory{MaxResults: *historyLimit}
8382

84-
logLevelProberValue, _ := level.Parse(*logLevelProber)
85-
logLevelProber := level.Allow(logLevelProberValue)
83+
allowedLevel := &promslog.AllowedLevel{}
84+
_ = allowedLevel.Set(*logLevelProber)
8685

87-
level.Info(logger).Log("msg", "Starting blackbox_exporter", "version", version.Info())
88-
level.Info(logger).Log("build_context", version.BuildContext())
86+
logger.Info("Starting blackbox_exporter", "version", version.Info())
87+
logger.Info(version.BuildContext())
8988

9089
if err := sc.ReloadConfig(*configFile, logger); err != nil {
91-
level.Error(logger).Log("msg", "Error loading config", "err", err)
90+
logger.Error("Error loading config", "err", err)
9291
return 1
9392
}
9493

9594
if *configCheck {
96-
level.Info(logger).Log("msg", "Config file is ok exiting...")
95+
logger.Info("Config file is ok exiting...")
9796
return 0
9897
}
9998

100-
level.Info(logger).Log("msg", "Loaded config file")
99+
logger.Info("Loaded config file")
101100

102101
// Infer or set Blackbox exporter externalURL
103102
listenAddrs := toolkitFlags.WebListenAddresses
104103
if *externalURL == "" && *toolkitFlags.WebSystemdSocket {
105-
level.Error(logger).Log("msg", "Cannot automatically infer external URL with systemd socket listener. Please provide --web.external-url")
104+
logger.Error("Cannot automatically infer external URL with systemd socket listener. Please provide --web.external-url")
106105
return 1
107106
} else if *externalURL == "" && len(*listenAddrs) > 1 {
108-
level.Info(logger).Log("msg", "Inferring external URL from first provided listen address")
107+
logger.Info("Inferring external URL from first provided listen address")
109108
}
110109
beURL, err := computeExternalURL(*externalURL, (*listenAddrs)[0])
111110
if err != nil {
112-
level.Error(logger).Log("msg", "failed to determine external URL", "err", err)
111+
logger.Error("failed to determine external URL", "err", err)
113112
return 1
114113
}
115-
level.Debug(logger).Log("externalURL", beURL.String())
114+
logger.Debug(beURL.String())
116115

117116
// Default -web.route-prefix to path of -web.external-url.
118117
if *routePrefix == "" {
@@ -126,7 +125,7 @@ func run() int {
126125
if *routePrefix != "/" {
127126
*routePrefix = *routePrefix + "/"
128127
}
129-
level.Debug(logger).Log("routePrefix", *routePrefix)
128+
logger.Debug(*routePrefix)
130129

131130
hup := make(chan os.Signal, 1)
132131
reloadCh := make(chan chan error)
@@ -136,16 +135,16 @@ func run() int {
136135
select {
137136
case <-hup:
138137
if err := sc.ReloadConfig(*configFile, logger); err != nil {
139-
level.Error(logger).Log("msg", "Error reloading config", "err", err)
138+
logger.Error("Error reloading config", "err", err)
140139
continue
141140
}
142-
level.Info(logger).Log("msg", "Reloaded config file")
141+
logger.Info("Reloaded config file")
143142
case rc := <-reloadCh:
144143
if err := sc.ReloadConfig(*configFile, logger); err != nil {
145-
level.Error(logger).Log("msg", "Error reloading config", "err", err)
144+
logger.Error("Error reloading config", "err", err)
146145
rc <- err
147146
} else {
148-
level.Info(logger).Log("msg", "Reloaded config file")
147+
logger.Info("Reloaded config file")
149148
rc <- nil
150149
}
151150
}
@@ -187,7 +186,7 @@ func run() int {
187186
sc.Lock()
188187
conf := sc.C
189188
sc.Unlock()
190-
prober.Handler(w, r, conf, logger, rh, *timeoutOffset, nil, moduleUnknownCounter, logLevelProber)
189+
prober.Handler(w, r, conf, logger, rh, *timeoutOffset, nil, moduleUnknownCounter, allowedLevel)
191190
})
192191
http.HandleFunc(*routePrefix, func(w http.ResponseWriter, r *http.Request) {
193192
w.Header().Set("Content-Type", "text/html")
@@ -256,7 +255,7 @@ func run() int {
256255
c, err := yaml.Marshal(sc.C)
257256
sc.RUnlock()
258257
if err != nil {
259-
level.Warn(logger).Log("msg", "Error marshalling configuration", "err", err)
258+
logger.Warn("Error marshalling configuration", "err", err)
260259
http.Error(w, err.Error(), http.StatusInternalServerError)
261260
return
262261
}
@@ -271,15 +270,15 @@ func run() int {
271270

272271
go func() {
273272
if err := web.ListenAndServe(srv, toolkitFlags, logger); err != nil {
274-
level.Error(logger).Log("msg", "Error starting HTTP server", "err", err)
273+
logger.Error("Error starting HTTP server", "err", err)
275274
close(srvc)
276275
}
277276
}()
278277

279278
for {
280279
select {
281280
case <-term:
282-
level.Info(logger).Log("msg", "Received SIGTERM, exiting gracefully...")
281+
logger.Info("Received SIGTERM, exiting gracefully...")
283282
return 0
284283
case <-srvc:
285284
return 1

0 commit comments

Comments
 (0)