There are two ways we can do this.
One is via the Log Browser in the Dashboard.
Where we can have access to request and gateway metadata related to the API call. Fields like Timestamp and Latency are especially helpful information when trying to figure out delays in API calls.
The other is via the logs, where we have access to different log levels that allow us to alter its verbosity depending on our needs.
For debugging purposes, setting the TYK_LOGLEVEL = debug will show us helpful timings which are recorded as the request / call passes through the gateway. More information on setting debug mode here: https://tyk.io/docs/log-data/#setting-via-environment-variable
A simple get request via Postman to a locally hosted API would give us the following debug logs:
Where the middleware components each record how long they took to complete. For this log, it is shown that the step took ns=439785292 (nanoseconds).
The first entry in the log:
A field ts=1722410231276277586 at the end is the epoch nanoseconds timestamp of when this step in processing the API started.
Once the internal processing of the API is complete, the gateway will then call the upstream target. This generates logs like the ones below:
Whether through the Log Browser or direct log analysis, taking note of these fields (ns, ts) gives us information on how long each step took and thus the time between one API call from another, helping identify delays and optimize performance.
Comments
0 comments
Please sign in to leave a comment.