Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(calling): set mediaEngine logger with webex logs for upload logs #4115

Open
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

rsarika
Copy link
Contributor

@rsarika rsarika commented Feb 25, 2025

COMPLETES #SPARK-616868

This pull request addresses

The uploaded logs from calling sdk to mats does not have Media layer(webrtc-media-core) logs.

by making the following changes

called setLogger of Media layer to assign webex logger so that upload logs will have logs of media layer.

webex-js-sdk_4288e710-ec5a-4895-adc5-80f339eec445.txt
webex-js-sdk_ea67d93f-7651-43c5-952c-16e36f86061a.txt

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

login to calling sdk with token and make a call.

end the call and click upload logs.

Expected: the logs should be uploaded to mats. and it should contain webrtc-media-core logs eg: initiateOffer() called

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.

@rsarika rsarika requested a review from a team as a code owner February 25, 2025 05:13
@rsarika rsarika requested a review from rarajes2 February 25, 2025 05:13
Copy link

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

The pull request introduces several changes focused on logging and testing improvements across multiple modules. In the CallingClient tests, a spy is added for the setLogger method imported from the internal media module to verify its invocation during error handling with an invalid Mobius service URL. The CallingClient implementation configures an adapted logger to forward logging calls to the existing webex.logger, which is then passed to the media engine using the setLogger method. The SDK’s test suite has been refactored to remove a custom mock Webex object, instead using SDKConnector to retrieve the Webex instance when uploading logs. Additionally, a minor update in the Logger type renames a parameter, while the test utilities have been modified to include a more structured support object with a submitLogs method. These changes enhance logging instrumentation and test coverage without altering core functionality.

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning glob@7.2.3: Glob versions prior to v9 are no longer supported
warning intern > glob@7.1.7: Glob versions prior to v9 are no longer supported
warning intern > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning mocha > glob@7.2.0: Glob versions prior to v9 are no longer supported
warning mocha > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning sinon@9.2.4: 16.1.1
warning sinon > @sinonjs/samsam > lodash.get@4.4.2: This package is deprecated. Use the optional chaining (?.) operator instead.
warning wd > archiver > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning wd > archiver > archiver-utils > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning wd > request@2.88.0: request has been deprecated, see request/request#3142
warning wd > request > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > q@1.5.1: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > request > har-validator@5.1.5: this library is no longer supported
warning @babel/cli > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/plugin-proposal-export-namespace-from@7.18.9: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > sinon@9.2.4: 16.1.1
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/plugin-proposal-export-namespace-from@7.18.9: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-5044ae76-7b8a-48a3-93a5-99db143d4a55 > @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
[2/4] Fetching packages...
error eslint-plugin-jsdoc@40.3.0: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98d6705 and ffcaf34.

📒 Files selected for processing (1)
  • packages/calling/src/common/Utils.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/calling/src/common/Utils.ts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Test - Unit
  • GitHub Check: Test - Style
  • GitHub Check: Test - Integration
  • GitHub Check: Test - Browser
  • GitHub Check: Test - Coverage
  • GitHub Check: AWS Amplify Console Web Preview

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rsarika rsarika requested a review from bhabalan February 25, 2025 05:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/calling/src/common/Utils.ts (1)

1557-1561: Improved uploadLogs function by removing redundant parameter.

Refactored the function to directly retrieve the Webex instance from SDKConnector rather than requiring it as a parameter. This simplifies the function signature and centralizes the WebexSDK instance retrieval approach.

Consider adding error type information for better error handling:

-export async function uploadLogs(data = {}) {
+export async function uploadLogs(data: Record<string, unknown> = {}): Promise<void> {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9abc67c and 8dee1ce.

📒 Files selected for processing (6)
  • packages/calling/src/CallingClient/CallingClient.test.ts (3 hunks)
  • packages/calling/src/CallingClient/CallingClient.ts (1 hunks)
  • packages/calling/src/SDKConnector/types.ts (1 hunks)
  • packages/calling/src/common/Utils.test.ts (2 hunks)
  • packages/calling/src/common/Utils.ts (1 hunks)
  • packages/calling/src/common/testUtil.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (10)
packages/calling/src/SDKConnector/types.ts (1)

47-47: Improved parameter naming for consistency.

Renaming the parameter from mess to payload enhances code readability and consistency, as it now matches the parameter naming used in other logging methods in the same interface.

packages/calling/src/CallingClient/CallingClient.test.ts (3)

2-2: Added Media module import for logger testing.

The import provides access to the media core module for testing the new logger integration.


57-57: Added spy for Media.setLogger to verify integration.

This spy allows for verification that the logger is correctly integrated with the media engine during tests.


102-102: Verified logger integration in invalid URL scenario.

The assertion confirms that the media engine logger is properly set up even when the Mobius service URL is invalid, ensuring robust logging across error conditions.

packages/calling/src/CallingClient/CallingClient.ts (1)

123-133: Added media engine logger integration.

Implements the core fix for SPARK-616868 by integrating Webex logger with the media engine. The adaptedLogger object correctly maps each log level method to the corresponding Webex logger method, ensuring that logs from the media layer are now included in log uploads to MATS.

The implementation properly joins multiple arguments into a single string before passing to the Webex logger, which handles the various logging format requirements.

packages/calling/src/common/testUtil.ts (1)

64-66: Enhanced mock structure for webex support object.

The change from using a simple mock function to a structured object with submitLogs method better represents the actual implementation structure, which will improve test fidelity for log submission tests.

packages/calling/src/common/Utils.test.ts (4)

60-60: Added SDKConnector import for centralized Webex instance management.

This import allows tests to use a singleton pattern for accessing the Webex instance, making test management more consistent.


67-67: Setting Webex instance in SDKConnector for centralized access.

This ensures that tests uniformly access the same Webex instance through SDKConnector rather than using direct references.


1563-1567: Refactored uploadLogs test to use centralized Webex instance.

The test now retrieves the Webex instance via SDKConnector instead of passing it directly, which aligns with the approach used in the implementation code. This is a good pattern for ensuring consistency across the codebase.


1571-1575: Updated error handling test to use SDKConnector.

The test now correctly mocks the rejection through the centralized SDKConnector instance, ensuring that the error handling test is properly validating the implementation.

@rsarika rsarika added the validated If the pull request is validated for automation. label Feb 25, 2025
Copy link
Contributor

@sreenara sreenara left a comment

Choose a reason for hiding this comment

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

There needs to be a way to configure the level of the media core logs too. Can we ensure we provide a setting for this?

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4115.d3m3l2kee0btzx.amplifyapp.com

@rsarika
Copy link
Contributor Author

rsarika commented Feb 25, 2025

There needs to be a way to configure the level of the media core logs too. Can we ensure we provide a setting for this?

@sreenara we are completely replacing the logger(using setLogger). so the level also gets effected in the media core logs. so in the console we see whatever we pass in config while initialising webex/callingclient.

But for uploading logs we upload complete buffer(irrespective of level) as per current logic in webex logger package.

@rsarika rsarika requested a review from sreenara February 25, 2025 09:43
Comment on lines +123 to +130
const adaptedLogger: Media.Logger = {
log: (...args) => webex.logger.log(args.join(' ')),
error: (...args) => webex.logger.error(args.join(' ')),
warn: (...args) => webex.logger.warn(args.join(' ')),
info: (...args) => webex.logger.info(args.join(' ')),
trace: (...args) => webex.logger.trace(args.join(' ')),
debug: (...args) => webex.logger.debug(args.join(' ')),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, Let's avoid space separated logs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

media layer uses console log which prints space separated. so using the same.
attached the downloaded log for reference.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sreenara @mkesavan13 What's your thought on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@rarajes2 @rsarika I think we should have a meeting for this. I'm not sure what this discussion is about.
@rsarika where is the attached download log? I'm not able to find it.

@rsarika rsarika requested a review from rarajes2 February 27, 2025 15:24
Copy link
Contributor

@bhabalan bhabalan left a comment

Choose a reason for hiding this comment

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

Please address the comments from others before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants