feat: add generic network telemetry - #5146
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ac771df13
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * @returns {string} | ||
| */ | ||
| function getFailureType(reason: RequestFailure, statusCode: number) { | ||
| const errorName = typeof reason?.name === 'string' ? reason.name.toLowerCase() : ''; |
There was a problem hiding this comment.
Classify wrapped timeout errors as timeouts
When a request-level timeout has no HTTP response, the SDK can surface it as a NetworkOrCORSError with statusCode: 0 while the original transport error is wrapped on the response body/code/message (for example the node request wrapper resolves a status-0 response with body: error). Since this only inspects the wrapper name, those timed-out SDK requests are reported as network_error instead of timeout, which undercounts the new timeout dimension; consider checking the wrapped error/code/message or timeout metadata before falling back to network_error.
Useful? React with 👍 / 👎.
| name: NETWORK_REQUEST_FAILURE_METRIC, | ||
| props: { | ||
| type: 'operational', | ||
| tags: { |
There was a problem hiding this comment.
I am not sure about the use of the tags. I did not understand codex answer....
540ffd2 to
dd62848
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd62848f06
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return ( | ||
| toString(wrappedError?.message) || | ||
| toString(typeof reason.body === 'string' ? reason.body : undefined) || | ||
| toString(reason.message) || |
There was a problem hiding this comment.
Sanitize fallback HTTP error messages
When a WebexHttpError has no body.message (for example an empty or non-standard 4xx/5xx body), webex-core's WebexHttpError.parse() appends the request URI and WEBEX_TRACKING_ID to reason.message. Falling back to that raw message here means each retry or failed response gets a unique errorMessage, so isSameError() won't aggregate it and tracking IDs bypass the ten-ID cap in trackingIds; please strip the appended request/tracking details or use a bounded fallback before putting it in telemetry.
Useful? React with 👍 / 👎.
dd62848 to
2f0dd84
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f0dd8479b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| } | ||
|
|
||
| safeSetInterval(submitSummary, NETWORK_TELEMETRY_INTERVAL_MS); |
There was a problem hiding this comment.
Clear the telemetry interval on logout
When a Webex instance is logged out or discarded, this interval still holds the bound submitMetric callback and keeps calling submitClientMetrics every ten minutes. Because the returned timer handle is discarded, the SDK cannot clear it from an onBeforeLogout or teardown path, so old/logged-out instances can keep submitting empty summaries and stay retained; store the handle and clear it during metrics cleanup/logout.
Useful? React with 👍 / 👎.
2f0dd84 to
bf4c9bc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf4c9bc661
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| telemetry.metricsSummary.totalRecvdResponse += 1; | ||
| getRequestMetric(telemetry, options).count_recvdResponse += 1; |
There was a problem hiding this comment.
Avoid double-counting replayed auth successes
In expired-token flows, AuthInterceptor.replay() (packages/@webex/webex-core/src/interceptors/auth.js:146-165) calls this.webex.request(options) before the original reversed response chain reaches RequestEventInterceptor (packages/@webex/http-core/src/request/index.js:36-37), so the replay emits its own request:success and then the original chain emits another success for that same replay response. Since this handler increments on every success event, those requests record two received responses but no failed 401 response/error, skewing the new failed-response and error telemetry; consider ignoring the outer replay success or recording handled 401s before auth swallows them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Codex recommends fix is to change interceptor ordering in webex-core, not add replay-specific logic to telemetry.
I'll consider it out of scope
bf4c9bc to
44468fe
Compare
| * @returns {string} | ||
| */ | ||
| function normalizeRouteSegment(segment: string) { | ||
| if (segment.length > 32 || segment.includes('%')) { |
There was a problem hiding this comment.
Questions:
- Are you sure this cover all cases?
- Why 32?
- Which identifier contains
%?
| count_sendRequest: number; | ||
| count_failedRequest: number; | ||
| count_recvdResponse: number; | ||
| count_failedResponse: number; |
There was a problem hiding this comment.
issue: please always use camelCase variable ad property names in JS, eg: countSendRequest
| * @param {unknown} value | ||
| * @returns {string|undefined} | ||
| */ | ||
| function toString(value: unknown) { |
There was a problem hiding this comment.
Please use type annotation only one place. Since other SDK code put all typings into the JSDoc, please do the same. But if you have typing in the docs you do not need to do them in the code
| function toString(value: unknown) { | |
| function toString(value) { |
same for the rest of the definitions
|
|
||
| return ( | ||
| toString(wrappedError?.message) || | ||
| toString(typeof reason.body === 'string' ? reason.body : undefined) || |
There was a problem hiding this comment.
toString already have a string typeof check, would it work like this instead:
| toString(typeof reason.body === 'string' ? reason.body : undefined) || | |
| toString(reason.body) || |
COMPLETES #SPARK-821340
This pull request addresses
Today, we have nothing in the logs that helps us track volume of requests made by the app and to where they go, we probably want a general request logger to be able to track this information for a session
by making the following changes
Add a generic telemetry on network requests
Change Type
The following scenarios were tested
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.