Skip to content
New issue

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

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

Already on GitHub? # to your account

BCDA-7415: add transaction id to middleware for all routers #165

Merged
merged 5 commits into from
Mar 21, 2024

Conversation

laurenkrugen-navapbc
Copy link
Contributor

🎫 Ticket

https://jira.cms.gov/browse/BCDA-7415

🛠 Changes

  • transaction ID is generated for every request if one is not present in the request header
  • SetCtxEntry was not returning ctx with new log fields; updated now to do so

ℹ️ Context for reviewers

Other work in 7415 involves a 'TrackingID' that is generated either as bytes or as a UUID. The TrackingID is meant to correlate log messages; the transaction ID configuration in BCDA app is the agreed upon implementation for correlating logs. For the sake of consistency and for correlating logs for requests as soon as they come in and complete, this has been updated.

✅ Acceptance Validation

Tests are present in other file that will be in a future PR; changes are tightly coupled and to keep this PR small, validation was done locally. Here are the logs for a POST request to the group endpoint:

    "application":"ssas",
    "environment":"local",
    "http_method":"POST",
    "http_proto":"HTTP/",
    "http_scheme":"http",
    "level":"info",
    "msg":"request started",
    "remote_addr":"<ip>",
    "request_id":"...",
    "time":"2024-03-20T18:09:20.15080251Z",
    "transaction_id":"25385708-080d-4bad-aa06-8f81ddc6ea17",
    "ts":"2024-03-20T18:09:20.150715552Z",
    "uri":"http://localhost:<port>/group",
    "user_agent":"PostmanRuntime/7.36.3",
    "version":"latest"
    }
2024-03-20 11:09:20 {
    "Op":"CreateGroup",
    "TrackingID":"1fa647ba",
    "application":"ssas",
    "environment":"local",
    "level":"info",
    "msg":"calling from admin.createGroup()",
    "request_id":"...",
    "time":"2024-03-20T18:09:20.304471552Z",
    "transaction_id":"25385708-080d-4bad-aa06-8f81ddc6ea17",
    "version":"latest"
    }

2024-03-20 11:09:20 {
    "application":"ssas",
    "environment":"local",
    "http_method":"POST",   
    "http_proto":"HTTP/",
    "http_scheme":"http",
    "level":"info",
    "msg":"request complete",
    "remote_addr":"<ip>",
    "request_id":"...",
    "resp_bytes_length":365,
    "resp_elapsed_ms":164.220125,
    "resp_status":201,
    "time":"2024-03-20T18:09:20.315763302Z",
    "transaction_id":"25385708-080d-4bad-aa06-8f81ddc6ea17",
    "ts":"2024-03-20T18:09:20.150715552Z",
    "uri":"http://localhost:<port>/group",
    "user_agent":"PostmanRuntime/7.36.3",
    "version":"latest"
    }

🔒 Security Implications

  • This PR adds a new software dependency or dependencies.
  • This PR modifies or invalidates one or more of our security controls.
  • This PR stores or transmits data that was not stored or transmitted before.
  • This PR requires additional review of its security implications for other reasons.

If any security implications apply, add Jason Ashbaugh (GitHub username: StewGoin) as a reviewer and do not merge this PR without his approval.

Copy link
Contributor

@alex-dzeda alex-dzeda 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, thanks for dealing with the CI errors. Glad to see transaction_id be passed between apps.

@laurenkrugen-navapbc laurenkrugen-navapbc merged commit 9a89d26 into master Mar 21, 2024
3 checks passed
@laurenkrugen-navapbc laurenkrugen-navapbc deleted the lauren/BCDA-7415-transaction-id branch March 21, 2024 17:49
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants