-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PP-5762 Add correlation id to logging
Add middleware to store the correlation on the commonLoggingFields object on the request so that it will be included in logs.
- Loading branch information
1 parent
d49b4c0
commit 0540f97
Showing
2 changed files
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict' | ||
|
||
const { CORRELATION_ID } = require('@govuk-pay/pay-js-commons').logging.keys | ||
const { CORRELATION_HEADER } = require('../../config/correlation_header') | ||
const { setLoggingField } = require('../utils/logging_fields_helper') | ||
|
||
module.exports = (req, res, next) => { | ||
req.correlationId = req.headers[CORRELATION_HEADER] || '' | ||
setLoggingField(req, CORRELATION_ID, req.correlationId) | ||
next() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters