cloud-sdk-js icon indicating copy to clipboard operation
cloud-sdk-js copied to clipboard

How to have correlation ids for messages from Cloud SDK in kibana?

Open dinurp opened this issue 2 years ago • 4 comments

We are using Cloud SDK v3 via CAP nodejs v7 for making external calls. We have enabled logging with Kibana formatter by enabling the setting in CAP. We have bound application log service to the app when it is deployed to SAP BTP Cloud Foundry. The messages from CAP are logged in Kibana together with request logs from Cloud Foundry with correlation ID. Even the messages send from the CAP application have correlation ID headers and we are able to see messages for a request across the different apps and systems.

But messages from Cloud SDK are without correlation ID. They float around in Kibana and are not easily found. Cloud SDK logs warning messages like "WarningJWT: The provided JWT payload does not include a 'user_id' property." These messages are logged with no context and we are not able to understand the relevance of these messages without correlation with other messages.

How can we get Cloud SDK messages to be logged with correlation ID? They are already logged in Kibana format. But, without correlation with their context, these messages are pretty useless. We are not able to take heed of the warnings or locate reasons of errors.

Regards, Dinu

dinurp avatar Oct 18 '23 13:10 dinurp

Hey @dinurp, this is a relevant feature request and we have discussed a similar issue in the past. Back then we still supported node 12 and which would have made it quite difficult to pass a context (e.g. the correlation ID) around. Now with node 18, this should be possible, however the context would have to be passed to the execute() functions somehow. This is definitely possible, we just have to discuss priorities.

marikaner avatar Oct 20 '23 15:10 marikaner

Passing additional parameters to execute() will need to be adopted by CAP to be useful to us. We will not be able to use it till then, just like we are not able to use resilience functionality now. The correlation id is already in the request header when CAP makes the request, can't that be used? Can we configure somehow setting the logging format? Is there a way I could configure SDK to use the same logger as used by CAP or something like cf-nodejs-logging-support that integrates with express to capture the request context?

dinurp avatar Oct 21 '23 04:10 dinurp

As of today this is not possible - we would need to implement some changes to make it possible.

marikaner avatar Oct 23 '23 11:10 marikaner