feat: do not use logger.Debug in critical path

This commit is contained in:
wpetit 2024-10-02 12:13:26 +02:00
parent 9bd1d0fbd7
commit 382d17cc85

View File

@ -41,21 +41,11 @@ func (d *Director) rewriteRequest(r *http.Request) (*http.Request, error) {
for _, p := range proxies {
for _, from := range p.From {
logger.Debug(
ctx, "matching request with proxy's from",
logger.F("from", from),
)
if matches := wildcard.Match(url.String(), from); !matches {
continue
}
logger.Debug(
ctx, "proxy's from matched",
logger.F("from", from),
)
ctx = logger.With(ctx,
proxyCtx := logger.With(ctx,
logger.F("proxy", p.Name),
logger.F("host", r.Host),
logger.F("remoteAddr", r.RemoteAddr),
@ -63,7 +53,7 @@ func (d *Director) rewriteRequest(r *http.Request) (*http.Request, error) {
metricProxyRequestsTotal.With(prometheus.Labels{metricLabelProxy: string(p.Name)}).Add(1)
proxyLayers, err := d.getLayers(ctx, p.Name)
proxyLayers, err := d.getLayers(proxyCtx, p.Name)
if err != nil {
return r, errors.WithStack(err)
}
@ -83,8 +73,8 @@ func (d *Director) rewriteRequest(r *http.Request) (*http.Request, error) {
r.URL.Scheme = toURL.Scheme
r.URL.Path = toURL.JoinPath(r.URL.Path).Path
ctx = withLayers(ctx, layers)
r = r.WithContext(ctx)
proxyCtx = withLayers(proxyCtx, layers)
r = r.WithContext(proxyCtx)
return r, nil
}