Skip to content

Commit a72fbd7

Browse files
authored
fix: stop scrape logger spam, refactor scrape logger design (#1381)
* fix: stop scrape logger spam, refactor scrape logger design Based on discussion in #1377, slack, etc, it seems unclear what the intended functionality/behavior of the probe scrape logger was supposed to be. This is an attempt to align behavior with current user expectations. The improved defaults and updated configs here should address the log spam as well. User facing changes: - the `--log.prober` flag now sets the _level at which prober scrape logs will be emitted at_. - the `--log.prober` flag now defaults to `debug` level. Because the default log level is info, this means that in order to see probe scrape logs, a user must either: - increase the level of the logger via `--log.level` to be >= that of `--log.prober` (ie, set both to `debug`) - decrease the level of the probe logger via `--log.prober` to be <= that of `--log.level` (ie, set both to `info`) Note: This approach (emitting all logs from the probe logger at the level specified) involves hijacking calls to the logger and overriding the level. This comes with the very obvious side effect that the developers working on code using the probe scrape logger no longer have control over the control over the level of the log that gets emitted. Regardless of whether they use `l.Info()` or `l.Debug()`, it'll still get logged at the configured log prober level. This approach likely would not be compatible with some of the other discussions around how probe scrape logs work, like #1401. Signed-off-by: TJ Hoplock <t.hoplock@gmail.com> * docs(README): add section on --log.prober behavior with sample output Address PR feedback Signed-off-by: TJ Hoplock <t.hoplock@gmail.com> --------- Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
1 parent 280f557 commit a72fbd7

File tree

4 files changed

+162
-41
lines changed

4 files changed

+162
-41
lines changed

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,123 @@ using the `--web.config.file` parameter. The format of the file is described
5050
Note that the TLS and basic authentication settings affect all HTTP endpoints:
5151
/metrics for scraping, /probe for probing, and the web UI.
5252

53+
### Controlling log level for probe logs
54+
55+
It is possible to control the level at which probe logs related to a scrape are output as.
56+
57+
Probe logs default to `debug` level, and can be controlled by the `--log.prober` flag.
58+
This means that probe scrape logs will not be output unless the level configured for the probe logger via `--log.prober` is >= the level configured for the blackbox_exporter via `--log.level`.
59+
60+
Sample output demonstrating the use and effect of these flags can be seen below.
61+
62+
> _Note_
63+
>
64+
> All log samples below used the following basic `blackbox.yml` configuration file and contain the probe logs of a single scrape generated by `curl`
65+
66+
```bash
67+
# blackbox.yml
68+
modules:
69+
http_2xx:
70+
prober: http
71+
72+
# generate probe
73+
curl "http://localhost:9115/probe?target=prometheus.io&module=http_2xx"
74+
```
75+
76+
<details>
77+
<summary>Example output with `--log.level=info` and `--log.prober=debug` (default)</summary>
78+
79+
```bash
80+
./blackbox_exporter --config.file ./blackbox.yml --log.level=info --log.prober=debug
81+
time=2025-05-21T04:10:54.131Z level=INFO source=main.go:88 msg="Starting blackbox_exporter" version="(version=0.26.0, branch=fix/scrape-logger-spam, revision=7df3031feecba82f1a534336979b4e5920f79b72)"
82+
time=2025-05-21T04:10:54.131Z level=INFO source=main.go:89 msg="(go=go1.24.1, platform=linux/amd64, user=tjhop@contraband, date=20250521-04:00:25, tags=unknown)"
83+
time=2025-05-21T04:10:54.132Z level=INFO source=main.go:101 msg="Loaded config file"
84+
time=2025-05-21T04:10:54.133Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9115
85+
time=2025-05-21T04:10:54.133Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9115
86+
^Ctime=2025-05-21T04:11:03.619Z level=INFO source=main.go:283 msg="Received SIGTERM, exiting gracefully..."
87+
```
88+
</details>
89+
90+
<details>
91+
<summary>Example output with `--log.level=info` and `--log.prober=info`</summary>
92+
93+
```bash
94+
./blackbox_exporter --config.file ./blackbox.yml --log.level=info --log.prober=info
95+
time=2025-05-21T04:12:09.884Z level=INFO source=main.go:88 msg="Starting blackbox_exporter" version="(version=0.26.0, branch=fix/scrape-logger-spam, revision=7df3031feecba82f1a534336979b4e5920f79b72)"
96+
time=2025-05-21T04:12:09.884Z level=INFO source=main.go:89 msg="(go=go1.24.1, platform=linux/amd64, user=tjhop@contraband, date=20250521-04:00:25, tags=unknown)"
97+
time=2025-05-21T04:12:09.884Z level=INFO source=main.go:101 msg="Loaded config file"
98+
time=2025-05-21T04:12:09.885Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9115
99+
time=2025-05-21T04:12:09.885Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9115
100+
time=2025-05-21T04:12:13.827Z level=INFO source=handler.go:194 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
101+
time=2025-05-21T04:12:13.827Z level=INFO source=handler.go:194 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
102+
time=2025-05-21T04:12:13.829Z level=INFO source=handler.go:194 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=172.67.201.240
103+
time=2025-05-21T04:12:13.829Z level=INFO source=handler.go:194 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://172.67.201.240 host=prometheus.io
104+
time=2025-05-21T04:12:13.860Z level=INFO source=handler.go:194 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
105+
time=2025-05-21T04:12:13.860Z level=INFO source=handler.go:194 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
106+
time=2025-05-21T04:12:13.860Z level=INFO source=handler.go:194 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=172.67.201.240 address=prometheus.io
107+
time=2025-05-21T04:12:13.974Z level=INFO source=handler.go:194 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
108+
time=2025-05-21T04:12:13.974Z level=INFO source=handler.go:194 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2025-05-21T00:12:13.829-04:00 dnsDone=2025-05-21T00:12:13.829-04:00 connectDone=2025-05-21T00:12:13.839-04:00 gotConn=2025-05-21T00:12:13.839-04:00 responseStart=2025-05-21T00:12:13.860-04:00 tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
109+
time=2025-05-21T04:12:13.974Z level=INFO source=handler.go:194 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2025-05-21T00:12:13.860-04:00 dnsDone=2025-05-21T00:12:13.861-04:00 connectDone=2025-05-21T00:12:13.869-04:00 gotConn=2025-05-21T00:12:13.925-04:00 responseStart=2025-05-21T00:12:13.974-04:00 tlsStart=2025-05-21T00:12:13.869-04:00 tlsDone=2025-05-21T00:12:13.925-04:00 end=2025-05-21T00:12:13.974-04:00
110+
time=2025-05-21T04:12:13.974Z level=INFO source=handler.go:194 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=0.14708839
111+
^Ctime=2025-05-21T04:12:17.818Z level=INFO source=main.go:283 msg="Received SIGTERM, exiting gracefully..."
112+
```
113+
</details>
114+
115+
<details>
116+
<summary>Example output with `--log.level=debug` and `--log.prober=info`</summary>
117+
118+
```bash
119+
./blackbox_exporter --config.file ./blackbox.yml --log.level=debug --log.prober=info
120+
time=2025-05-21T04:13:18.497Z level=INFO source=main.go:88 msg="Starting blackbox_exporter" version="(version=0.26.0, branch=fix/scrape-logger-spam, revision=7df3031feecba82f1a534336979b4e5920f79b72)"
121+
time=2025-05-21T04:13:18.497Z level=INFO source=main.go:89 msg="(go=go1.24.1, platform=linux/amd64, user=tjhop@contraband, date=20250521-04:00:25, tags=unknown)"
122+
time=2025-05-21T04:13:18.497Z level=INFO source=main.go:101 msg="Loaded config file"
123+
time=2025-05-21T04:13:18.498Z level=DEBUG source=main.go:116 msg=http://contraband:9115
124+
time=2025-05-21T04:13:18.498Z level=DEBUG source=main.go:130 msg=/
125+
time=2025-05-21T04:13:18.498Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9115
126+
time=2025-05-21T04:13:18.498Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9115
127+
time=2025-05-21T04:13:23.169Z level=INFO source=handler.go:194 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
128+
time=2025-05-21T04:13:23.169Z level=INFO source=handler.go:194 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
129+
time=2025-05-21T04:13:23.170Z level=INFO source=handler.go:194 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=104.21.60.220
130+
time=2025-05-21T04:13:23.170Z level=INFO source=handler.go:194 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://104.21.60.220 host=prometheus.io
131+
time=2025-05-21T04:13:23.202Z level=INFO source=handler.go:194 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
132+
time=2025-05-21T04:13:23.202Z level=INFO source=handler.go:194 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
133+
time=2025-05-21T04:13:23.202Z level=INFO source=handler.go:194 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=104.21.60.220 address=prometheus.io
134+
time=2025-05-21T04:13:23.316Z level=INFO source=handler.go:194 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
135+
time=2025-05-21T04:13:23.319Z level=INFO source=handler.go:194 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2025-05-21T00:13:23.171-04:00 dnsDone=2025-05-21T00:13:23.171-04:00 connectDone=2025-05-21T00:13:23.181-04:00 gotConn=2025-05-21T00:13:23.181-04:00 responseStart=2025-05-21T00:13:23.201-04:00 tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
136+
time=2025-05-21T04:13:23.319Z level=INFO source=handler.go:194 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2025-05-21T00:13:23.202-04:00 dnsDone=2025-05-21T00:13:23.203-04:00 connectDone=2025-05-21T00:13:23.212-04:00 gotConn=2025-05-21T00:13:23.268-04:00 responseStart=2025-05-21T00:13:23.316-04:00 tlsStart=2025-05-21T00:13:23.212-04:00 tlsDone=2025-05-21T00:13:23.268-04:00 end=2025-05-21T00:13:23.319-04:00
137+
time=2025-05-21T04:13:23.319Z level=INFO source=handler.go:194 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=0.150580389
138+
^Ctime=2025-05-21T04:13:27.945Z level=INFO source=main.go:283 msg="Received SIGTERM, exiting gracefully..."
139+
```
140+
</details>
141+
142+
143+
<details>
144+
<summary>Example output with `--log.level=debug` and `--log.prober=debug`</summary>
145+
146+
```bash
147+
./blackbox_exporter --config.file ./blackbox.yml --log.level=debug --log.prober=debug
148+
time=2025-05-21T04:14:55.621Z level=INFO source=main.go:88 msg="Starting blackbox_exporter" version="(version=0.26.0, branch=fix/scrape-logger-spam, revision=7df3031feecba82f1a534336979b4e5920f79b72)"
149+
time=2025-05-21T04:14:55.621Z level=INFO source=main.go:89 msg="(go=go1.24.1, platform=linux/amd64, user=tjhop@contraband, date=20250521-04:00:25, tags=unknown)"
150+
time=2025-05-21T04:14:55.622Z level=INFO source=main.go:101 msg="Loaded config file"
151+
time=2025-05-21T04:14:55.622Z level=DEBUG source=main.go:116 msg=http://contraband:9115
152+
time=2025-05-21T04:14:55.622Z level=DEBUG source=main.go:130 msg=/
153+
time=2025-05-21T04:14:55.623Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9115
154+
time=2025-05-21T04:14:55.623Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9115
155+
time=2025-05-21T04:15:03.048Z level=DEBUG source=handler.go:194 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
156+
time=2025-05-21T04:15:03.049Z level=DEBUG source=handler.go:194 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
157+
time=2025-05-21T04:15:03.050Z level=DEBUG source=handler.go:194 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=172.67.201.240
158+
time=2025-05-21T04:15:03.050Z level=DEBUG source=handler.go:194 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://172.67.201.240 host=prometheus.io
159+
time=2025-05-21T04:15:03.089Z level=DEBUG source=handler.go:194 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
160+
time=2025-05-21T04:15:03.089Z level=DEBUG source=handler.go:194 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
161+
time=2025-05-21T04:15:03.089Z level=DEBUG source=handler.go:194 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=172.67.201.240 address=prometheus.io
162+
time=2025-05-21T04:15:03.211Z level=DEBUG source=handler.go:194 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
163+
time=2025-05-21T04:15:03.212Z level=DEBUG source=handler.go:194 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2025-05-21T00:15:03.050-04:00 dnsDone=2025-05-21T00:15:03.050-04:00 connectDone=2025-05-21T00:15:03.061-04:00 gotConn=2025-05-21T00:15:03.061-04:00 responseStart=2025-05-21T00:15:03.089-04:00 tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
164+
time=2025-05-21T04:15:03.212Z level=DEBUG source=handler.go:194 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2025-05-21T00:15:03.089-04:00 dnsDone=2025-05-21T00:15:03.090-04:00 connectDone=2025-05-21T00:15:03.102-04:00 gotConn=2025-05-21T00:15:03.163-04:00 responseStart=2025-05-21T00:15:03.211-04:00 tlsStart=2025-05-21T00:15:03.102-04:00 tlsDone=2025-05-21T00:15:03.163-04:00 end=2025-05-21T00:15:03.212-04:00
165+
time=2025-05-21T04:15:03.212Z level=DEBUG source=handler.go:194 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=0.163695815
166+
^Ctime=2025-05-21T04:15:07.862Z level=INFO source=main.go:283 msg="Received SIGTERM, exiting gracefully..."
167+
```
168+
</details>
169+
53170
## Building the software
54171

55172
### Local Build

main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050
configFile = kingpin.Flag("config.file", "Blackbox exporter configuration file.").Default("blackbox.yml").String()
5151
timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64()
5252
configCheck = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool()
53-
logLevelProber = kingpin.Flag("log.prober", "Log level from probe requests. One of: [debug, info, warn, error]").Default("info").String()
53+
logLevelProber = kingpin.Flag("log.prober", "Log level for probe request logs. One of: [debug, info, warn, error]. Defaults to debug. Please see the section `Controlling log level for probe logs` in the project README for more information.").Default("debug").String()
5454
historyLimit = kingpin.Flag("history.limit", "The maximum amount of items to keep in the history.").Default("100").Uint()
5555
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()
5656
routePrefix = kingpin.Flag("web.route-prefix", "Prefix for the internal routes of web endpoints. Defaults to path of --web.external-url.").PlaceHolder("<path>").String()
@@ -80,8 +80,10 @@ func run() int {
8080
logger := promslog.New(promslogConfig)
8181
rh := &prober.ResultHistory{MaxResults: *historyLimit}
8282

83-
allowedLevel := promslog.NewLevel()
84-
_ = allowedLevel.Set(*logLevelProber)
83+
probeLogLevel := promslog.NewLevel()
84+
if err := probeLogLevel.Set(*logLevelProber); err != nil {
85+
logger.Warn("Error setting log prober level, log prober level unchanged", "err", err, "current_level", probeLogLevel.String())
86+
}
8587

8688
logger.Info("Starting blackbox_exporter", "version", version.Info())
8789
logger.Info(version.BuildContext())
@@ -186,7 +188,7 @@ func run() int {
186188
sc.Lock()
187189
conf := sc.C
188190
sc.Unlock()
189-
prober.Handler(w, r, conf, logger, rh, *timeoutOffset, nil, moduleUnknownCounter, allowedLevel)
191+
prober.Handler(w, r, conf, logger, rh, *timeoutOffset, nil, moduleUnknownCounter, promslogConfig.Level, probeLogLevel)
190192
})
191193
http.HandleFunc(*routePrefix, func(w http.ResponseWriter, r *http.Request) {
192194
w.Header().Set("Content-Type", "text/html")

prober/handler.go

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package prober
1616
import (
1717
"bytes"
1818
"context"
19-
"errors"
2019
"fmt"
2120
"log/slog"
2221
"net/http"
@@ -45,7 +44,7 @@ var (
4544

4645
func Handler(w http.ResponseWriter, r *http.Request, c *config.Config, logger *slog.Logger, rh *ResultHistory, timeoutOffset float64, params url.Values,
4746
moduleUnknownCounter prometheus.Counter,
48-
logLevelProber *promslog.Level) {
47+
logLevel, logLevelProber *promslog.Level) {
4948

5049
if params == nil {
5150
params = r.URL.Query()
@@ -110,13 +109,7 @@ func Handler(w http.ResponseWriter, r *http.Request, c *config.Config, logger *s
110109
}
111110
}
112111

113-
if logLevelProber == nil {
114-
logLevelProber = promslog.NewLevel()
115-
}
116-
if logLevelProber.String() == "" {
117-
_ = logLevelProber.Set("info")
118-
}
119-
sl := newScrapeLogger(logger, moduleName, target, logLevelProber)
112+
sl := newScrapeLogger(logger, moduleName, target, logLevel, logLevelProber)
120113
slLogger := slog.New(sl)
121114

122115
slLogger.Info("Beginning probe", "probe", module.Prober, "timeout_seconds", timeoutSeconds)
@@ -166,10 +159,10 @@ func setHTTPHost(hostname string, module *config.Module) error {
166159
}
167160

168161
type scrapeLogger struct {
169-
next *slog.Logger
170-
buffer bytes.Buffer
171-
bufferLogger *slog.Logger
172-
logLevel *promslog.Level
162+
next *slog.Logger
163+
buffer bytes.Buffer
164+
bufferLogger *slog.Logger
165+
logLevelProber *promslog.Level
173166
}
174167

175168
// Enabled returns true if both A) the scrapeLogger's internal `next` logger
@@ -187,44 +180,53 @@ func (sl *scrapeLogger) Enabled(ctx context.Context, level slog.Level) bool {
187180
// the internal bufferLogger for use with serving debug output. It implements
188181
// slog.Handler.
189182
func (sl *scrapeLogger) Handle(ctx context.Context, r slog.Record) error {
190-
var errs []error
183+
level := getSlogLevel(sl.logLevelProber.String())
184+
185+
// Collect attributes from record so we can log them directly. We
186+
// hijack log calls to the scrapeLogger and override the level from the
187+
// original log call with the level set via the `--log.prober` flag.
188+
attrs := make([]slog.Attr, r.NumAttrs())
189+
r.Attrs(func(a slog.Attr) bool {
190+
attrs = append(attrs, a)
191+
return true
192+
})
191193

192-
errs = append(errs, sl.next.Handler().Handle(ctx, r.Clone()))
194+
sl.next.LogAttrs(ctx, level, r.Message, attrs...)
195+
sl.bufferLogger.LogAttrs(ctx, level, r.Message, attrs...)
193196

194-
if sl.bufferLogger.Enabled(context.Background(), getSlogLevel(sl.logLevel.String())) {
195-
errs = append(errs, sl.bufferLogger.Handler().Handle(ctx, r.Clone()))
196-
}
197-
198-
return errors.Join(errs...)
197+
return nil
199198
}
200199

201200
// WithAttrs adds the provided attributes to the scrapeLogger's internal logger and
202201
// bufferLogger. It implements slog.Handler.
203202
func (sl *scrapeLogger) WithAttrs(attrs []slog.Attr) slog.Handler {
204203
return &scrapeLogger{
205-
next: slog.New(sl.next.Handler().WithAttrs(attrs)),
206-
buffer: sl.buffer,
207-
bufferLogger: slog.New(sl.bufferLogger.Handler().WithAttrs(attrs)),
208-
logLevel: sl.logLevel,
204+
next: slog.New(sl.next.Handler().WithAttrs(attrs)),
205+
buffer: sl.buffer,
206+
bufferLogger: slog.New(sl.bufferLogger.Handler().WithAttrs(attrs)),
207+
logLevelProber: sl.logLevelProber,
209208
}
210209
}
211210

212211
// WithGroup adds the provided group name to the scrapeLogger's internal logger
213212
// and bufferLogger. It implements slog.Handler.
214213
func (sl *scrapeLogger) WithGroup(name string) slog.Handler {
215214
return &scrapeLogger{
216-
next: slog.New(sl.next.Handler().WithGroup(name)),
217-
buffer: sl.buffer,
218-
bufferLogger: slog.New(sl.bufferLogger.Handler().WithGroup(name)),
219-
logLevel: sl.logLevel,
215+
next: slog.New(sl.next.Handler().WithGroup(name)),
216+
buffer: sl.buffer,
217+
bufferLogger: slog.New(sl.bufferLogger.Handler().WithGroup(name)),
218+
logLevelProber: sl.logLevelProber,
220219
}
221220
}
222221

223-
func newScrapeLogger(logger *slog.Logger, module string, target string, logLevel *promslog.Level) *scrapeLogger {
222+
func newScrapeLogger(logger *slog.Logger, module string, target string, logLevel, logLevelProber *promslog.Level) *scrapeLogger {
223+
if logLevelProber == nil {
224+
logLevelProber = promslog.NewLevel()
225+
}
224226
sl := &scrapeLogger{
225-
next: logger.With("module", module, "target", target),
226-
buffer: bytes.Buffer{},
227-
logLevel: logLevel,
227+
next: logger.With("module", module, "target", target),
228+
buffer: bytes.Buffer{},
229+
logLevelProber: logLevelProber,
228230
}
229231
bl := promslog.New(&promslog.Config{Writer: &sl.buffer, Level: logLevel})
230232
sl.bufferLogger = bl.With("module", module, "target", target)

0 commit comments

Comments
 (0)