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

Log the resource type associated with a download job #767

Merged
merged 4 commits into from
Apr 28, 2022

Conversation

whytheplatypus
Copy link
Contributor

@whytheplatypus whytheplatypus commented Apr 26, 2022

  • starts a pattern for adding fields to the contextual log (the log associated with the request).
  • using middleware to decorate functions with additional request level logging.

Fixes PACA-429

Proposed Changes

  • Moving to structured logging
  • Upping test coverage
  • Experimenting with CI pipeline checks

Change Details

Using the structured contextual logging provided by the chi middleware

Security Implications

None: adding only one non-pii/phi field to logging.

  • new software dependencies
    None
  • security controls or supporting software altered
  • new data stored or transmitted
  • security checklist is completed for this change
  • requires more information or team discussion to evaluate security implications
  • no PHI/PII is affected by this change

Acceptance Validation

Feedback Requested

- starts a pattern for adding fields to the contextual log (the log associated with the request).
- using middleware to decorate functions with additional request level logging.
v1 stopped working in feb 2022
@lgtm-com
Copy link

lgtm-com bot commented Apr 26, 2022

This pull request introduces 1 alert and fixes 1 when merging 102c94a into 3dbc1ed - view on LGTM.com

new alerts:

  • 1 for Incorrect conversion between integer types

fixed alerts:

  • 1 for Incorrect conversion between integer types

@whytheplatypus whytheplatypus marked this pull request as ready for review April 27, 2022 19:42
@lgtm-com
Copy link

lgtm-com bot commented Apr 27, 2022

This pull request introduces 1 alert and fixes 1 when merging 5d1cc75 into 3dbc1ed - view on LGTM.com

new alerts:

  • 1 for Incorrect conversion between integer types

fixed alerts:

  • 1 for Incorrect conversion between integer types

@lgtm-com
Copy link

lgtm-com bot commented Apr 27, 2022

This pull request fixes 1 alert when merging d31fbfb into 3dbc1ed - view on LGTM.com

fixed alerts:

  • 1 for Incorrect conversion between integer types

@codecov-commenter
Copy link

Codecov Report

Merging #767 (d31fbfb) into master (3dbc1ed) will increase coverage by 0.52%.
The diff coverage is 89.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #767      +/-   ##
==========================================
+ Coverage   65.94%   66.46%   +0.52%     
==========================================
  Files          65       65              
  Lines        5875     8126    +2251     
==========================================
+ Hits         3874     5401    +1527     
- Misses       1540     2262     +722     
- Partials      461      463       +2     
Impacted Files Coverage Δ
bcda/api/v1/api.go 56.25% <ø> (+1.51%) ⬆️
bcda/logging/middleware.go 91.76% <86.66%> (-2.83%) ⬇️
bcda/web/router.go 92.13% <100.00%> (+2.58%) ⬆️
bcdaworker/worker/bluebutton.go 42.22% <0.00%> (-7.78%) ⬇️
bcda/auth/ssas.go 51.63% <0.00%> (-3.33%) ⬇️
bcda/models/models.go 88.88% <0.00%> (-2.78%) ⬇️
bcda/auth/client/ssas.go 45.91% <0.00%> (-2.66%) ⬇️
bcda/cclf/testutils/cclfUtils.go 75.18% <0.00%> (-2.49%) ⬇️
bcda/alr/gen/synthetic.go 84.54% <0.00%> (-2.42%) ⬇️
bcda/database/connection.go 61.53% <0.00%> (-2.26%) ⬇️
... and 58 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3dbc1ed...d31fbfb. Read the comment docs.

Copy link
Contributor

@4ell0 4ell0 left a comment

Choose a reason for hiding this comment

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

Looks good


func (rl *ResourceTypeLogger) LogJobResourceType(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r)
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I reading this correctly that only a 200 response from v1.ServeData will result in the resource type being logged? Not necessarily a bad thing, just wanted to make sure I was interpreting this middleware function correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should run regardless, although if ServeData isn't returning a 200 it's likely that the same thing that caused that will mean there's no ResourceType to log (e.g. the job id was wrong, or something)

Copy link
Contributor

@ericbuckley ericbuckley left a comment

Choose a reason for hiding this comment

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

looks great, thanks for moving this into middleware

Copy link
Contributor

@ian-sawyer ian-sawyer left a comment

Choose a reason for hiding this comment

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

Looks great!

@whytheplatypus whytheplatypus merged commit c72a8a6 into master Apr 28, 2022
@whytheplatypus whytheplatypus deleted the whytheplatypus/log-download-resource-type branch April 28, 2022 17:13
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.

6 participants