CPS-2796: CPS core logs should contain requestID and clientID
References
CPS-2796: Add request ID and client ID in cps-core logs Submitted
Issues/Decisions
Date | Item | Owner | Notes | Relevant Links |
|---|---|---|---|---|
|
|
| Action |
|
Description
Enhance CPS Core logging by including requestID and clientID in all log entries. This will enable end-to-end traceability of requests originating from other ONAP components. CPS REST APIs will accept requestID and clientID in the request headers, and they can include these identifiers in the request headers. CPS Core will then propagate these IDs throughout its logging system,
creating a complete audit trail that makes it easy to trace requests from start to finish across the entire distributed system.
Proposed changes
To implement the above functionality, the following changes are required :-
HTTP Servlet Interceptor
Introduce an interceptor to filter all incoming HTTP requests in CPS REST APIs.
Extract the request headers (X-CPS-Request-Id and X-CPS-Client-Id) and map them to MDC as X-CPS-Request-Id and X-CPS-Client-Id.Logging Configuration
Update logback-spring.xml to include X-CPS-Request-Id and X-CPS-Client-Id in the log format.
This ensures all logs will carry these identifiers for improved traceability across ONAP components.
Attach clientId and requestId to Log Context for Improved Traceability
{"logTimeStamp":"2025-10-08T03:59:49.619Z","logLevel":"WARN","traceId":"1f859fe779a5ca74805822f38e906eeb",
"requestId":"test_X-CPS-Request-Id","clientId":"test_X-CPS-Client-Id","principalId":"GM001016278","serviceName":"cps-application"
,"message":"SQL Error: 0, SQLState: 23505","spanId":"7a68990c36d59582","processId":"7288","threadName":"qtp1370756928-28",
"class":"o.h.engine.jdbc.spi.SqlExceptionHelper"}
Challenges
Since we are intercepting the REST APIs and filtering the HTTP headers, we need to check if there are any performance issues in execution on REST calls