Skip to content

Swap to rails_semantic_logger - #984

Merged
JPrevost merged 1 commit into
mainfrom
TIMX-678
Sep 4, 2026
Merged

Swap to rails_semantic_logger#984
JPrevost merged 1 commit into
mainfrom
TIMX-678

Conversation

@JPrevost

Copy link
Copy Markdown
Member

Builds a few individual logging lines into a single rich line

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • ANDI or Wave has been run in accordance to
    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)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Requires database migrations?

NO

Includes new or updated dependencies?

YES

@qltysh

qltysh Bot commented Aug 20, 2026

Copy link
Copy Markdown

❌ 2 blocking issues (2 total)

Tool Category Rule Count
rubocop Lint Method has too many lines. [15/10] 1
rubocop Lint Assignment Branch Condition size for search is too high. [<8, 26, 4> 27.5/17] 1

@mitlib
mitlib temporarily deployed to timdex-api-p-timx-678-omrhobye August 20, 2026 19:58 Inactive
@JPrevost
JPrevost had a problem deploying to timdex-api-p-timx-678-omrhobye August 25, 2026 18:56 Failure
@JPrevost
JPrevost had a problem deploying to timdex-api-p-timx-678-omrhobye August 25, 2026 19:01 Failure
used_deprecated_arguments: analyzer_data[:used_deprecated_arguments] || []
)

response

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment Branch Condition size for search is too high. [<8, 26, 4> 27.5/17] [rubocop:Metrics/AbcSize]

@JPrevost
JPrevost had a problem deploying to timdex-api-p-timx-678-omrhobye August 25, 2026 19:11 Failure
@JPrevost
JPrevost temporarily deployed to timdex-api-p-timx-678-omrhobye August 25, 2026 19:17 Inactive
@JPrevost JPrevost closed this Sep 2, 2026
@JPrevost JPrevost reopened this Sep 2, 2026
@mitlib
mitlib temporarily deployed to timdex-api-p-timx-678-gxzhgubc September 2, 2026 13:38 Inactive
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
@JPrevost
JPrevost temporarily deployed to timdex-api-p-timx-678-gxzhgubc September 4, 2026 11:30 Inactive
@JPrevost
JPrevost marked this pull request as ready for review September 4, 2026 11:30
@JPrevost
JPrevost requested a lite review from Copilot September 4, 2026 12:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 lograge and its initializer; configure rails_semantic_logger appenders 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_print for 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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very French: << les informations >>

Comment on lines 19 to +20
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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I agree, but the linters auto-fix it to this so it's pointless to fight the bots on it.

@jazairi jazairi self-assigned this Sep 4, 2026
@JPrevost
JPrevost merged commit ca36025 into main Sep 4, 2026
4 checks passed
@JPrevost
JPrevost deleted the TIMX-678 branch September 4, 2026 17:37
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.

4 participants