Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally include IP info at start of search/find linked data requests #302

Merged
merged 2 commits into from
Dec 16, 2019

Conversation

elrayle
Copy link
Contributor

@elrayle elrayle commented Dec 13, 2019

Marks the start of each linked data search/find request. Unless Qa.config.suppress_ip_data_from_log, this marker will include IP address, city, state, and country as reported by the geocoder gem.

NOTE: This also removes inclusion of the request_id directly in the logging messages. To include request_id, it is recommended that you set up the logger to do this automatically in config/environments/development.rb (or relevant env file) using…

config.log_tags = [:request_id]

Marks the start of each linked data search/find request.  Unless `Qa.config.suppress_ip_data_from_log`, this marker will include IP address, city, state, and country as reported by the `geocoder` gem.

NOTE: This also removes inclusion of the request_id directly in the logging messages.  To include request_id, it is recommended that you set up the logger to do this automatically in `config/environments/development.rb` (or relevant env file) using…

```
config.log_tags = [:request_id]
```
@@ -16,7 +17,8 @@ class RequestHeaderService
def initialize(request:, params:)
@request = request
@params = params
@request_id = assign_request_id
@request_id = request.request_id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to assign a new one since each request comes with an id

@id = id
url = authority_service.build_url(action_config: term_config, action: :term, action_request: normalize_id, request_header: request_header)
Rails.logger.info "#{request_id} - QA Linked Data term url: #{url}"
Rails.logger.info "QA Linked Data term url: #{url}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several places where #{request_id} is removed. The same effect can be achieved with standard logging features. See PR notes for more info.

@@ -2,6 +2,7 @@
require 'json'

describe Qa::LinkedDataTermsController, type: :controller do
let(:graph_load_failure) { /^\*\*\*\*\*\*\*\* RDF\:\:Graph\#load failure/ }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pattern for catching new graph load failure logging. Exact failure is will be driven by the exception thrown and does not require validation here. The required validation is that the logging occurred. This pattern allows for that validation.

@elrayle elrayle merged commit 876112e into master Dec 16, 2019
@elrayle elrayle deleted the log_ip branch December 16, 2019 20:11
@jrochkind
Copy link
Contributor

Is it a concern that geocode-lookup of every IP address for log line may take non-trivial amounts of time, and add to response times when such logging is turned on?

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.

None yet

3 participants