Skip to content

Commit

Permalink
Standardizing how we enable request logs handler (knative#12118)
Browse files Browse the repository at this point in the history
* make enabling request logs more recognizable

* fixes
  • Loading branch information
psschwei authored Oct 8, 2021
1 parent d575aca commit 24f3646
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ func buildServer(ctx context.Context, env config, healthState *health.State, pro

composedHandler = health.ProbeHandler(healthState, probeContainer, tracingEnabled, composedHandler)
composedHandler = network.NewProbeHandler(composedHandler)
// We might want sometimes capture the probes/healthchecks in the request
// We might sometimes want to capture the probes/healthchecks in the request
// logs. Hence we need to have RequestLogHandler to be the first one.
composedHandler = pushRequestLogHandler(logger, composedHandler, env)
if env.ServingEnableRequestLog {
composedHandler = requestLogHandler(logger, composedHandler, env)
}

return pkgnet.NewServer(":"+env.QueueServingPort, composedHandler)
}
Expand Down Expand Up @@ -411,11 +413,7 @@ func buildMetricsServer(promStatReporter *queue.PrometheusStatsReporter, protobu
}
}

func pushRequestLogHandler(logger *zap.SugaredLogger, currentHandler http.Handler, env config) http.Handler {
if !env.ServingEnableRequestLog {
return currentHandler
}

func requestLogHandler(logger *zap.SugaredLogger, currentHandler http.Handler, env config) http.Handler {
revInfo := &pkghttp.RequestLogRevision{
Name: env.ServingRevision,
Namespace: env.ServingNamespace,
Expand Down

0 comments on commit 24f3646

Please sign in to comment.