feat: add structured wide event logging#5
Merged
jordangarrison merged 13 commits intomainfrom Feb 20, 2026
Merged
Conversation
Canonical log line / wide event pattern for structured JSON logging across GitHub API calls, Poller GenServer, LiveView sessions, and HTTP requests using LoggerJSON + custom WideEvent module.
8-task TDD implementation plan covering LoggerJSON setup, WideEvent core module, Req logger plugin, HTTP telemetry handler, Poller integration, and LiveView logging.
- Add logger_json ~> 7.0 dependency - Replace default formatter with LoggerJSON.Formatters.Basic - Suppress default Phoenix request logging (handled via telemetry) - Set dev log level to :debug for wide event visibility - Add LOG_LEVEL runtime env var override
Add Greenlight.WideEvent module that wraps Logger.metadata/1 for accumulating context and provides emit/3 for structured event emission with automatic timing and error capture via with_context/3.
Req plugin that emits wide events for every GitHub API call with request/response metadata including endpoint, status, duration, response size, and rate limit headers. Logs at debug for 2xx, info for rate limit warnings (<100 remaining), error for 4xx/5xx.
Logger.metadata/1 only sets metadata on the calling process. The environment context (app_version, node, env, git_sha) was not appearing in log events from Poller, LiveView, or HTTP request handler processes. Switch to :logger.update_primary_config/1 which sets metadata globally for all processes, ensuring environment context appears in every event.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Greenlight.WideEventcore module for accumulating context and emitting single context-rich events per logical operationGreenlight.GitHub.ReqLoggerReq plugin that automatically logs every GitHub API call with endpoint, status, duration, response size, and rate limit infoGreenlight.RequestLoggertelemetry handler for HTTP request logging via[:phoenix, :endpoint, :stop]:logger.update_primary_config/1so environment context appears in all process logsTest Plan
mix format --check-formattedpassesmix compile --warnings-as-errorspassesLOG_LEVEL=debug mix phx.server