Skip to content

fix: apply log level/format before NewRunner() emits startup logs#1192

Open
ucpr wants to merge 1 commit into
envoyproxy:mainfrom
ucpr:fix/log-format-before-runner-init
Open

fix: apply log level/format before NewRunner() emits startup logs#1192
ucpr wants to merge 1 commit into
envoyproxy:mainfrom
ucpr:fix/log-format-before-runner-init

Conversation

@ucpr

@ucpr ucpr commented Jul 16, 2026

Copy link
Copy Markdown

Summary

When LOG_FORMAT=json was set, startup logs emitted before the logger configuration was applied used logrus’s default text formatter.

This affected Stats-related logs emitted from NewRunner() and tracing initialization logs emitted early in Run(). Logs emitted later, such as the Redis connection log, used the configured JSON formatter. As a result, a single process produced logs in inconsistent formats.

time="2026-07-16T03:20:52Z" level=info msg="Stats initialized for Prometheus"
time="2026-07-16T03:20:52Z" level=info msg="Starting prometheus sink on :9090/rate-limit-metrics"
time="2026-07-16T03:20:52Z" level=info msg="Stats flush interval: 30s"
time="2026-07-16T03:20:52Z" level=info msg="TracerProvider initialized with following parameters: ..."
{"@message":"connecting to redis on 127.0.0.1:6379 with pool size 64","@timestamp":"...","level":"warning"}

Fix

Extracted the logger level/format configuration into configureLogger() and call it at the top of NewRunner(), so it's applied before any log line is emitted, including those inside NewRunner() itself. Removed the now-duplicated configuration code from Run().

Note: #428 was a prior attempt at the same root cause, but it only reordered the TracerProvider initialized log inside Run() and didn't address the Stats-related logs emitted from NewRunner(). It went unreviewed and was stale-closed. This PR covers both.

Test plan

  • go build ./...
  • go test ./src/...
  • Ran locally with LOG_FORMAT=json and confirmed all startup logs (Stats initialized / Stats flush interval / Tracing disabled / etc.) are now emitted as JSON

@ucpr
ucpr force-pushed the fix/log-format-before-runner-init branch from 45f5de5 to fd7ec83 Compare July 16, 2026 05:53
@ucpr
ucpr marked this pull request as ready for review July 16, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant