cloud-sdk-js
cloud-sdk-js copied to clipboard
Make logging less verbose when an error happens in @sap-cloud-sdk/http-client
When an HTTP query fails in @sap-cloud-sdk/http-client I get h huge error message with a lot of information I don't care about.
Describe the solution you'd like Make logging less verbose. E.g. I'd like to see the response code and the response payload and that's it. Most of the space in the log is taken up by a binary buffer which contains the session cache. I'm pretty sure moste people don't want to see it and don't go to the hassle of decoding it.
Describe alternatives you've considered If making it less verbose is not possible, make it configurable.
Impact / Priority
Affected development phase: Development, Release, Production
Impact: Inconvenience Log JSON here:
{
"date": "Fri Mar 04 2022 10:14:29 GMT+0100 (Central European Standard Time)",
"error": {
"config": {
"baseURL": "redacted",
"data": "redacted",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Length": 379,
"Content-Type": "application/json",
"User-Agent": "axios/0.26.0",
"authorization": "Basic redacted"
},
"httpAgent": {
"_events": {},
"_eventsCount": 2,
"defaultPort": 80,
"freeSockets": {},
"keepAlive": false,
"keepAliveMsecs": 1000,
"maxFreeSockets": 256,
"maxSockets": null,
"maxTotalSockets": null,
"options": {
"path": null
},
"protocol": "http:",
"requests": {},
"scheduling": "lifo",
"sockets": {},
"totalSocketCount": 0
},
"httpsAgent": {
"_events": {},
"_eventsCount": 2,
"_sessionCache": {
"list": [
"redacted::::::::true:::::::::::::"
],
"map": {
"redacted::::::::true:::::::::::::": {
"data": ["gigantic array"],
"type": "Buffer"
}
}
},
"defaultPort": 443,
"freeSockets": {},
"keepAlive": false,
"keepAliveMsecs": 1000,
"maxCachedSessions": 100,
"maxFreeSockets": 256,
"maxSockets": null,
"maxTotalSockets": null,
"options": {
"path": null,
"rejectUnauthorized": true
},
"protocol": "https:",
"requests": {},
"scheduling": "lifo",
"sockets": {
"redacted::::::::true:::::::::::::": [
{
"_SNICallback": null,
"_controlReleased": true,
"_events": {
"close": [
null,
null,
null,
null
]
},
"_eventsCount": 10,
"_hadError": false,
"_host": "redacted",
"_httpMessage": {
"_closed": false,
"_contentLength": null,
"_defaultKeepAlive": true,
"_ended": true,
"_events": {},
"_eventsCount": 7,
"_hasBody": true,
"_header": "redacted",
"_headerSent": true,
"_keepAliveTimeout": 0,
"_last": true,
"_redirectable": {
"_currentRequest": "[Circular]",
"_currentUrl": "redacted",
"_ended": true,
"_ending": true,
"_events": {},
"_eventsCount": 3,
"_options": {
"agent": "[Circular]",
"agents": {
"http": {
"_events": {},
"_eventsCount": 2,
"defaultPort": 80,
"freeSockets": {},
"keepAlive": false,
"keepAliveMsecs": 1000,
"maxFreeSockets": 256,
"maxSockets": null,
"maxTotalSockets": null,
"options": {
"path": null
},
"protocol": "http:",
"requests": {},
"scheduling": "lifo",
"sockets": {},
"totalSocketCount": 0
},
"https": "[Circular]"
},
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Length": 379,
"Content-Type": "application/json",
"User-Agent": "axios/0.26.0",
"authorization": "Basic redacted"
},
"hostname": "redacted",
"maxBodyLength": 10485760,
"maxRedirects": 21,
"method": "POST",
"nativeProtocols": {
"http:": {
"METHODS": [
"ACL",
"BIND",
"CHECKOUT",
"CONNECT",
"COPY",
"DELETE",
"GET",
"HEAD",
"LINK",
"LOCK",
"M-SEARCH",
"MERGE",
"MKACTIVITY",
"MKCALENDAR",
"MKCOL",
"MOVE",
"NOTIFY",
"OPTIONS",
"PATCH",
"POST",
"PROPFIND",
"PROPPATCH",
"PURGE",
"PUT",
"REBIND",
"REPORT",
"SEARCH",
"SOURCE",
"SUBSCRIBE",
"TRACE",
"UNBIND",
"UNLINK",
"UNLOCK",
"UNSUBSCRIBE"
],
"STATUS_CODES": {
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"103": "Early Hints",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
"206": "Partial Content",
"207": "Multi-Status",
"208": "Already Reported",
"226": "IM Used",
"300": "Multiple Choices",
"301": "Moved Permanently",
"302": "Found",
"303": "See Other",
"304": "Not Modified",
"305": "Use Proxy",
"307": "Temporary Redirect",
"308": "Permanent Redirect",
"400": "Bad Request",
"401": "Unauthorized",
"402": "Payment Required",
"403": "Forbidden",
"404": "Not Found",
"405": "Method Not Allowed",
"406": "Not Acceptable",
"407": "Proxy Authentication Required",
"408": "Request Timeout",
"409": "Conflict",
"410": "Gone",
"411": "Length Required",
"412": "Precondition Failed",
"413": "Payload Too Large",
"414": "URI Too Long",
"415": "Unsupported Media Type",
"416": "Range Not Satisfiable",
"417": "Expectation Failed",
"418": "I'm a Teapot",
"421": "Misdirected Request",
"422": "Unprocessable Entity",
"423": "Locked",
"424": "Failed Dependency",
"425": "Too Early",
"426": "Upgrade Required",
"428": "Precondition Required",
"429": "Too Many Requests",
"431": "Request Header Fields Too Large",
"451": "Unavailable For Legal Reasons",
"500": "Internal Server Error",
"501": "Not Implemented",
"502": "Bad Gateway",
"503": "Service Unavailable",
"504": "Gateway Timeout",
"505": "HTTP Version Not Supported",
"506": "Variant Also Negotiates",
"507": "Insufficient Storage",
"508": "Loop Detected",
"509": "Bandwidth Limit Exceeded",
"510": "Not Extended",
"511": "Network Authentication Required"
},
"globalAgent": {
"_events": {},
"_eventsCount": 2,
"defaultPort": 80,
"freeSockets": {},
"keepAlive": false,
"keepAliveMsecs": 1000,
"maxFreeSockets": 256,
"maxSockets": null,
"maxTotalSockets": null,
"options": {
"path": null
},
"protocol": "http:",
"requests": {},
"scheduling": "lifo",
"sockets": {},
"totalSocketCount": 0
},
"maxHeaderSize": 16384
},
"https:": {
"globalAgent": {
"_events": {},
"_eventsCount": 2,
"_sessionCache": {
"list": [
"redacted:::::::::::::::::::::"
],
"map": {
"redacted:::::::::::::::::::::": {
"data": ["gigantic array"],
"type": "Buffer"
}
}
},
"defaultPort": 443,
"freeSockets": {},
"keepAlive": false,
"keepAliveMsecs": 1000,
"maxCachedSessions": 100,
"maxFreeSockets": 256,
"maxSockets": null,
"maxTotalSockets": null,
"options": {
"path": null
},
"protocol": "https:",
"requests": {},
"scheduling": "lifo",
"sockets": {},
"totalSocketCount": 0
}
}
},
"path": "redacted",
"pathname": "redacted",
"port": "redacted",
"protocol": "https:"
},
"_redirectCount": 0,
"_redirects": [],
"_requestBodyBuffers": [],
"_requestBodyLength": 379,
"_writableState": {
"afterWriteTickInfo": null,
"allBuffers": true,
"allNoop": true,
"autoDestroy": true,
"bufferProcessing": false,
"buffered": [],
"bufferedIndex": 0,
"closeEmitted": false,
"closed": false,
"constructed": true,
"corked": 0,
"decodeStrings": true,
"defaultEncoding": "utf8",
"destroyed": false,
"emitClose": true,
"ended": false,
"ending": false,
"errorEmitted": false,
"errored": null,
"finalCalled": false,
"finished": false,
"highWaterMark": 16384,
"length": 0,
"needDrain": false,
"objectMode": false,
"pendingcb": 0,
"prefinished": false,
"sync": true,
"writecb": null,
"writelen": 0,
"writing": false
}
},
"_removedConnection": false,
"_removedContLen": false,
"_removedTE": false,
"_trailer": "",
"aborted": false,
"agent": "[Circular]",
"chunkedEncoding": false,
"destroyed": false,
"finished": true,
"host": "redacted",
"maxHeadersCount": null,
"maxRequestsOnConnectionReached": false,
"method": "POST",
"outputData": [],
"outputSize": 0,
"parser": null,
"path": "redacted",
"protocol": "https:",
"res": {
"_consuming": false,
"_dumped": false,
"_events": {
"end": [
null,
null
]
},
"_eventsCount": 4,
"_readableState": {
"autoDestroy": true,
"awaitDrainWriters": null,
"buffer": {
"head": null,
"length": 0,
"tail": null
},
"closeEmitted": true,
"closed": true,
"constructed": true,
"dataEmitted": true,
"decoder": null,
"defaultEncoding": "utf8",
"destroyed": true,
"emitClose": true,
"emittedReadable": false,
"encoding": null,
"endEmitted": true,
"ended": true,
"errorEmitted": false,
"errored": null,
"flowing": true,
"highWaterMark": 16384,
"length": 0,
"multiAwaitDrain": false,
"needReadable": false,
"objectMode": false,
"pipes": [],
"readableListening": false,
"reading": false,
"readingMore": true,
"resumeScheduled": false,
"sync": true
},
"aborted": false,
"client": "[Circular]",
"complete": true,
"httpVersion": "1.1",
"httpVersionMajor": 1,
"httpVersionMinor": 1,
"method": null,
"rawHeaders": [
"set-cookie",
"sap-usercontext=sap-client=redacted; path=/",
"content-type",
"text/html; charset=utf-8",
"content-length",
"9321",
"sap-system",
"redacted",
"www-authenticate",
"Basic realm=\"SAP NetWeaver Application Server [redacted/redacted]\"",
"sap-server",
"true",
"sap-perf-fesrec",
"7100.000000"
],
"rawTrailers": [],
"redirects": [],
"req": "[Circular]",
"responseUrl": "redacted",
"socket": "[Circular]",
"statusCode": 401,
"statusMessage": "Unauthorized",
"upgrade": false,
"url": ""
},
"reusedSocket": false,
"sendDate": false,
"shouldKeepAlive": false,
"socket": "[Circular]",
"timeoutCb": null,
"upgradeOrConnect": false,
"useChunkedEncodingByDefault": true,
"writable": true
},
"_newSessionPending": false,
"_parent": null,
"_pendingData": null,
"_pendingEncoding": "",
"_readableState": {
"autoDestroy": true,
"awaitDrainWriters": null,
"buffer": {
"head": null,
"length": 0,
"tail": null
},
"closeEmitted": false,
"closed": false,
"constructed": true,
"dataEmitted": true,
"decoder": null,
"defaultEncoding": "utf8",
"destroyed": false,
"emitClose": false,
"emittedReadable": false,
"encoding": null,
"endEmitted": false,
"ended": false,
"errorEmitted": false,
"errored": null,
"flowing": true,
"highWaterMark": 16384,
"length": 0,
"multiAwaitDrain": false,
"needReadable": true,
"objectMode": false,
"pipes": [],
"readableListening": false,
"reading": true,
"readingMore": false,
"resumeScheduled": false,
"sync": false
},
"_rejectUnauthorized": true,
"_requestCert": true,
"_secureEstablished": true,
"_securePending": false,
"_server": null,
"_sockname": null,
"_tlsOptions": {
"isServer": false,
"pipe": false,
"rejectUnauthorized": true,
"requestCert": true,
"secureContext": {
"context": {}
},
"session": {
"data": ["gigantic array!"],
"type": "Buffer"
}
},
"_writableState": {
"afterWriteTickInfo": null,
"allBuffers": true,
"allNoop": true,
"autoDestroy": true,
"bufferProcessing": false,
"buffered": [],
"bufferedIndex": 0,
"closeEmitted": false,
"closed": false,
"constructed": true,
"corked": 0,
"decodeStrings": false,
"defaultEncoding": "utf8",
"destroyed": false,
"emitClose": false,
"ended": true,
"ending": true,
"errorEmitted": false,
"errored": null,
"finalCalled": true,
"finished": false,
"highWaterMark": 16384,
"length": 0,
"needDrain": false,
"objectMode": false,
"pendingcb": 1,
"prefinished": false,
"sync": false,
"writecb": null,
"writelen": 0,
"writing": false
},
"allowHalfOpen": false,
"alpnProtocol": false,
"authorizationError": null,
"authorized": true,
"connecting": false,
"encrypted": true,
"parser": null,
"secureConnecting": false,
"servername": "redacted",
"ssl": {
"_parent": {
"onconnection": null,
"reading": true
},
"_secureContext": {
"context": {}
},
"reading": true
}
}
]
},
"totalSocketCount": 1
},
"maxBodyLength": -1,
"maxContentLength": -1,
"method": "post",
"params": {},
"proxy": false,
"timeout": 0,
"transformRequest": [
null
],
"transformResponse": [
null
],
"transitional": {
"clarifyTimeoutError": false,
"forcedJSONParsing": true,
"silentJSONParsing": true
},
"url": "redacted",
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN"
},
"message": "Request failed with status code 401",
"name": "Error",
"stack": "Error: Request failed with status code 401\n at createError (/path/to/repo/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/path/to/repo/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/path/to/repo/node_modules/axios/lib/adapters/http.js:322:11)\n at IncomingMessage.emit (node:events:532:35)\n at endReadableNT (node:internal/streams/readable:1346:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)",
"status": 401
},
"exception": true,
"level": "error",
"logger": "sap-cloud-sdk-logger",
"message": "uncaughtException: Request failed with status code 401\nError: Request failed with status code 401\n at createError (/path/to/repo/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/path/to/repo/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/path/to/repo/node_modules/axios/lib/adapters/http.js:322:11)\n at IncomingMessage.emit (node:events:532:35)\n at endReadableNT (node:internal/streams/readable:1346:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)",
"msg": "Error: Request failed with status code 401\n at createError (/path/to/repo/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/path/to/repo/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/path/to/repo/node_modules/axios/lib/adapters/http.js:322:11)\n at IncomingMessage.emit (node:events:532:35)\n at endReadableNT (node:internal/streams/readable:1346:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)",
"os": {
"loadavg": [
3.70361328125,
2.85693359375,
2.8369140625
],
"uptime": 395773
},
"process": {
"argv": [
"/user/path/.fnm/node-versions/v16.14.0/installation/bin/node",
"./src/main.ts"
],
"cwd": "/path/to/repo",
"execPath": "/user/path/.fnm/node-versions/v16.14.0/installation/bin/node",
"gid": 20,
"memoryUsage": {
"arrayBuffers": 18527059,
"external": 19630290,
"heapTotal": 48467968,
"heapUsed": 45119032,
"rss": 101142528
},
"pid": 87815,
"uid": 501,
"version": "v16.14.0"
},
"stack": "Error: Request failed with status code 401\n at createError (/path/to/repo/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/path/to/repo/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/path/to/repo/node_modules/axios/lib/adapters/http.js:322:11)\n at IncomingMessage.emit (node:events:532:35)\n at endReadableNT (node:internal/streams/readable:1346:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)",
"test": "exception",
"timestamp": "2022-03-04T09:14:29.088Z",
"trace": [
{
"column": 15,
"file": "/path/to/repo/node_modules/axios/lib/core/createError.js",
"function": "createError",
"line": 16,
"method": null,
"native": false
},
{
"column": 12,
"file": "/path/to/repo/node_modules/axios/lib/core/settle.js",
"function": "settle",
"line": 17,
"method": null,
"native": false
},
{
"column": 11,
"file": "/path/to/repo/node_modules/axios/lib/adapters/http.js",
"function": "IncomingMessage.handleStreamEnd",
"line": 322,
"method": "handleStreamEnd",
"native": false
},
{
"column": 35,
"file": "node:events",
"function": "IncomingMessage.emit",
"line": 532,
"method": "emit",
"native": false
},
{
"column": 12,
"file": "node:internal/streams/readable",
"function": "endReadableNT",
"line": 1346,
"method": null,
"native": false
},
{
"column": 21,
"file": "node:internal/process/task_queues",
"function": "processTicksAndRejections",
"line": 83,
"method": null,
"native": false
}
],
"written_at": "2022-03-04T09:14:29.088Z",
"written_ts": 1646385269088
}
Hey @brodo,
I see your point and will discuss it with the team on Monday.
I'll update you after the discussion.
Sorry for the late response, we are currently still planning the topics for the next quarter, however logging is one of our major considerations. Either way, we agree that the logs you mentioned should be improved.
Hey @brodo, we have improved the logs for HTTP responses. We will release a new minor version next week. You can also try it with the canary version before, if you want. Let us know, if you encounter any other issues with this.