Skip to content

Commit

Permalink
Log standardized client, side, route_path attributes.
Browse files Browse the repository at this point in the history
Make it easier to search & categorize request logs

- `client` is now always the client app id
- Added `side`: "client" for incoming request, "backend" for outgoing
- Also log `route_path` for outgoing requests
  • Loading branch information
joodie committed Jan 8, 2025
1 parent 601d329 commit 98ad035
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion policies/aggregation/aggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ module.exports = (config, { gatewayConfig: { serviceEndpoints } }) => {
// log and keep metrics for request to endpoint
const report = ({ statusCode, reqTimerEnd, ...rest }) => {
jsonLog.info({
client: 'PROXY',
client: app,
side: 'backend',
http_status: statusCode,
traceparent_id: outgoingTraceParent.id,
traceparent_parent_id: outgoingTraceParent.parent_id,
traceparent_trace_id: outgoingTraceParent.traceId,
route_path: req.route && req.route.path,
...rest
})

Expand Down
1 change: 1 addition & 0 deletions policies/lifecycle-logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = () => {
const statusCode = res.statusCode

const infoProps = {
side: 'client',
short_message: `${req.traceparent.traceId} - ${method} ${url} ${statusCode}`,
traceparent_trace_id: traceParent.traceId,
traceparent_id: traceParent.id,
Expand Down

0 comments on commit 98ad035

Please sign in to comment.