Conversation
❌ 2 blocking issues (2 total)
|
| used_deprecated_arguments: analyzer_data[:used_deprecated_arguments] || [] | ||
| ) | ||
|
|
||
| response |
Why are these changes being introduced: * Our new logging platform will support structured logging * While moving to JSON logs, it was worth understanding how to add custom fields to the log payload so this demonstrates with a few examples. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/TIMX-678 How does this address that need: * Removed Lograge and adds rails_semantic_logger * Builds a few individual logging lines into a single rich line
There was a problem hiding this comment.
🔵 Needs a closer look
It changes the production logging stack and request log payload behavior in ways that should be manually verified in real runtime/log aggregation before approval.
Pull request overview
This PR replaces the app’s request logging approach (previously Lograge + custom per-line logging) with rails_semantic_logger, aiming to emit richer single-line structured logs—especially for GraphQL search requests—by aggregating analyzer and resolver data into the request log payload.
Changes:
- Remove
logrageand its initializer; configurerails_semantic_loggerappenders for production (JSON) and development (color). - Refactor GraphQL request logging to collect analyzer output and per-search events into the controller log payload (via
append_info_to_payload), instead of ad-hoc logger lines and a custom tracer. - Add
amazing_printfor development/test.
File summaries
| File | Description |
|---|---|
| Gemfile.lock | Removes lograge/request_store, adds rails_semantic_logger + semantic_logger and amazing_print. |
| Gemfile | Swaps lograge for rails_semantic_logger; adds amazing_print to dev/test. |
| config/initializers/lograge.rb | Deletes Lograge configuration (params/time/host payload enrichment). |
| config/environments/production.rb | Configures Semantic Logger JSON output to stdout. |
| config/environments/development.rb | Configures Semantic Logger color output to stdout (with optional file appender commented). |
| app/graphql/types/query_type.rb | Stops per-request log line; pushes structured search event data into GraphQL context for controller payload logging. |
| app/graphql/timdex_request_tracer.rb | Removes custom GraphQL tracer previously used to expose analyzer data. |
| app/graphql/timdex_field_usage_analyzer.rb | Writes analyzer results directly to query.context[:graphql_analysis] and returns structured analysis data. |
| app/controllers/graphql_controller.rb | Adds @graphql_search_events collection and appends GraphQL-specific structured data into the Rails log payload. |
| app/controllers/application_controller.rb | Adds global log payload enrichment (host) and adjusts preferred-domain redirect URL construction. |
Review details
- Files reviewed: 9/10 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| private | ||
|
|
||
| # Appends additional information to the log payload that are not Controller specific |
There was a problem hiding this comment.
Very French: << les informations >>
| Rails.logger.info("Handling Domain Redirect: #{request.host}") | ||
| redirect_to "https://#{ENV['PREFERRED_DOMAIN']}", status: :moved_permanently, allow_other_host: true | ||
| redirect_to "https://#{ENV.fetch('PREFERRED_DOMAIN', nil)}", status: :moved_permanently, allow_other_host: true |
There was a problem hiding this comment.
FWIW I agree, but the linters auto-fix it to this so it's pointless to fight the bots on it.
Builds a few individual logging lines into a single rich line
Developer
our guide and
all issues introduced by these changes have been resolved or opened as new
issues (link to those issues in the Pull Request details above)
Code Reviewer
(not just this pull request message)
Requires database migrations?
NO
Includes new or updated dependencies?
YES