Skip to content

feat: add generic network telemetry - #5146

Open
pierrealexandre2 wants to merge 1 commit into
webex:nextfrom
pierrealexandre2:networkTelemetry
Open

feat: add generic network telemetry#5146
pierrealexandre2 wants to merge 1 commit into
webex:nextfrom
pierrealexandre2:networkTelemetry

Conversation

@pierrealexandre2

@pierrealexandre2 pierrealexandre2 commented Aug 4, 2026

Copy link
Copy Markdown

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@pierrealexandre2
pierrealexandre2 marked this pull request as ready for review August 4, 2026 09:09
@pierrealexandre2
pierrealexandre2 requested review from a team as code owners August 4, 2026 09:09

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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() : '';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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: {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the use of the tags. I did not understand codex answer....

@pierrealexandre2
pierrealexandre2 force-pushed the networkTelemetry branch 2 times, most recently from 540ffd2 to dd62848 Compare August 11, 2026 08:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +506 to +507
telemetry.metricsSummary.totalRecvdResponse += 1;
getRequestMetric(telemetry, options).count_recvdResponse += 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

* @returns {string}
*/
function normalizeRouteSegment(segment: string) {
if (segment.length > 32 || segment.includes('%')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions:

  1. Are you sure this cover all cases?
  2. Why 32?
  3. Which identifier contains %?

Comment on lines +24 to +27
count_sendRequest: number;
count_failedRequest: number;
count_recvdResponse: number;
count_failedResponse: number;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: please always use camelCase variable ad property names in JS, eg: countSendRequest

* @param {unknown} value
* @returns {string|undefined}
*/
function toString(value: unknown) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toString already have a string typeof check, would it work like this instead:

Suggested change
toString(typeof reason.body === 'string' ? reason.body : undefined) ||
toString(reason.body) ||

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants