Skip to content

Commit

Permalink
Drop the deprecated current_request.request_id
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Sep 30, 2024
1 parent 1ed2572 commit 1bdd9a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Removed
- **BREAKING** Remove the deprecated `current_request.request_id` [(#80)](https://github.com/ManageIQ/manageiq-loggers/pull/80)

## [1.2.0] - 2024-09-30
### Added
Expand Down
8 changes: 1 addition & 7 deletions lib/manageiq/loggers/json_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ def translate_error(level)
end

def request_id
Thread.current[:request_id] || Thread.current[:current_request]&.request_id.tap do |request_id|
if request_id
require "active_support"
require "active_support/deprecation"
ActiveSupport::Deprecation.warn("Usage of `Thread.current[:current_request]&.request_id` will be deprecated in version 0.5.0. Please switch to `Thread.current[:request_id]` to log request_id automatically.")
end
end
Thread.current[:request_id]
end
end
end
Expand Down
15 changes: 0 additions & 15 deletions spec/manageiq/json_logger_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ def expected_hash(time, message, request_id = nil)
expect(JSON.parse(result)).to eq(expected)
end
end

context "in deprecated :current_request" do
before { Thread.current[:current_request] = double(:request_id => request_id) }
after { Thread.current[:current_request] = nil }

it do
expect(ActiveSupport::Deprecation).to receive(:warn)

time = Time.now
result = formatter.call("INFO", time, "some_program", message)

expected = expected_hash(time, message, request_id)
expect(JSON.parse(result)).to eq(expected)
end
end
end

it "does not escape characters as in ActiveSupport::JSON extensions" do
Expand Down

0 comments on commit 1bdd9a2

Please sign in to comment.