Skip to content

OBPIH-6860 set log level to INFO in prod#4964

Merged
awalkowiak merged 1 commit intodevelopfrom
maintenance/OBPIH-6860-use-info-logs-in-prod
Jan 14, 2025
Merged

OBPIH-6860 set log level to INFO in prod#4964
awalkowiak merged 1 commit intodevelopfrom
maintenance/OBPIH-6860-use-info-logs-in-prod

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented Nov 28, 2024

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6860

Description: Demoted some noisy logs to DEBUG and added the ability to set log level per deployment method (development is staying at DEBUG, production is changed to INFO).

Some logs we won't see anymore on prod:

2024-11-15 21:55:21,368 DEBUG [-exec-4514] org.pih.warehouse.SentryInterceptor     : updated Sentry context for /openboxes/api/purchaseOrders in 0 ms
2024-11-15 21:55:21,368  INFO [-exec-4514] org.pih.warehouse.RoleInterceptor       : No rule for purchaseOrderApi:list -> allow anonymous
2024-11-15 21:55:21,369  INFO [-exec-4514] org.pih.warehouse.core.UserService      : Is role ROLE_ADMIN in [ROLE_MANAGER, ROLE_BROWSER, ROLE_ASSISTANT, ROLE_AUTHENTICATED, ROLE_SUPERUSER, ROLE_ADMIN] = true

📷 Screenshots & Recordings (optional)

If this PR contains a UI change, consider adding one or more screenshots here or link to a screen recording to help reviewers visualize the change. Otherwise, you can remove this section.

image

@ewaterman ewaterman self-assigned this Nov 28, 2024
@github-actions github-actions bot added type: maintenance Code improvements, optimizations and refactors, dependency upgrades... domain: backend Changes or discussions relating to the backend server flag: config change Hilights a pull request that contains a change to the app config labels Nov 28, 2024

// Now that we've populated the MDC, log the request itself, including query parameters.
String queryString = StringUtils.isBlank(request?.queryString) ? "" : "?${request?.queryString}"
log.info("${request.requestURI}${queryString} [user:${session?.user?.username}, location:${session?.warehouse?.name}]")
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved what was in AccessLogInterceptor to here since it felt like it should be encompassed by the logging interceptor. I also added the query parameters to the end of the request.

@ewaterman
Copy link
Member Author

No need to review this before the release. I was just needing a break from Cycle Count so I did this for fun.

@codecov
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 7.62%. Comparing base (3dae0b9) to head (2fd1256).
Report is 211 commits behind head on develop.

Files with missing lines Patch % Lines
...ollers/org/pih/warehouse/LoggingInterceptor.groovy 0.00% 2 Missing and 3 partials ⚠️
...ntrollers/org/pih/warehouse/RoleInterceptor.groovy 0.00% 2 Missing and 1 partial ⚠️
...services/org/pih/warehouse/core/UserService.groovy 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             develop   #4964   +/-   ##
=========================================
  Coverage       7.61%   7.62%           
  Complexity       816     816           
=========================================
  Files            600     599    -1     
  Lines          42275   42272    -3     
  Branches       10277   10281    +4     
=========================================
+ Hits            3221    3223    +2     
+ Misses         38586   38579    -7     
- Partials         468     470    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

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

@ewaterman overall this looks good to me, I think I never looked at the RoleInterceptor logs and usually I was irritated by them. I additionally looked if there are any log.debugs that we might miss after the change and I don't see anything required there (plus we could also change the level through openboxes-config.groovy config when we need to debug some user roles). I am good with the change, but would like to get an approval from @jmiranda as well.

@awalkowiak
Copy link
Collaborator

@ewaterman

No need to review this before the release. I was just needing a break from Cycle Count so I did this for fun.

And I read this after review 😅 but yeah my thought was that this does not have to go to the release yet.

@ewaterman ewaterman added the warn: do not merge Marks a pull request that is not yet ready to be merged label Dec 4, 2024
@ewaterman
Copy link
Member Author

marking this change as do not merge as we're going to wait until 0.9.3 is cut

@ewaterman ewaterman removed the warn: do not merge Marks a pull request that is not yet ready to be merged label Dec 11, 2024
Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

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

Look good.


// Now that we've populated the MDC, log the request itself, including query parameters.
String queryString = StringUtils.isBlank(request?.queryString) ? "" : "?${request?.queryString}"
log.info("${request.requestURI}${queryString} [user:${session?.user?.username}, location:${session?.warehouse?.name}]")
Copy link
Member

Choose a reason for hiding this comment

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

I think this is the log message that @awalkowiak doesn't like. I find it helpful to demarcate logging for requests along with the message that reports response time.

Aside: Now that I'm looking at the logs I'm noticing that the response time is no longer reported. @awalkowiak Do you know when that got removed?

Anyway, I can be overruled if others would prefer to remove it or make it a DEBUG message.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda this one I like. I often look at this one. The one I dislike that is causing a lot of garbage is the one in the UserService -> log.info "Is role ${role.roleType} in ${acceptedRoleTypes} = ${acceptedRoleType}" (and I am happy that it was demoted to debug level)

@awalkowiak awalkowiak merged commit c4766bb into develop Jan 14, 2025
@awalkowiak awalkowiak deleted the maintenance/OBPIH-6860-use-info-logs-in-prod branch January 14, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server flag: config change Hilights a pull request that contains a change to the app config type: maintenance Code improvements, optimizations and refactors, dependency upgrades...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants