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

Add option for MatrixClient.initRustCrypto() to disable tracing. #4462

Closed
wants to merge 3 commits into from

Conversation

Srayash
Copy link

@Srayash Srayash commented Oct 18, 2024

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • Sign-off given on the changes (see CONTRIBUTING.md).

Fixes

fixes #4177

Description

This PR introduces an optional parameter, tracingEnabled, to the initRustCrypto function, allowing users to enable or disable tracing in the Rust crypto SDK.

Now, the tracing feature can be toggled:

Enabled: tracingEnabled: true - Tracing will capture debug-level logs.
Disabled: tracingEnabled: false - No tracing will occur, leading to cleaner log output and improved performance.

Signed-off-by: Srayash [email protected]

@Srayash Srayash requested a review from a team as a code owner October 18, 2024 12:10
@Srayash Srayash requested review from andybalaam and uhoreg October 18, 2024 12:10
@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Oct 18, 2024
@richvdh richvdh self-requested a review October 18, 2024 12:59
Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

The change looks ok to me, but I want to defer to the other reviewers as to whether this the right way to do this.

@andybalaam
Copy link
Member

This error from the build looks genuine though:

src/rust-crypto/index.ts:108:65 - error TS2339: Property 'Off' does not exist on type 'typeof LoggerLevel'.

108 new RustSdkCryptoJs.Tracing(RustSdkCryptoJs.LoggerLevel.Off).turnOn();
~~~

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

Changes needed to fix the build

@Srayash
Copy link
Author

Srayash commented Oct 18, 2024

hey @andybalaam the error can be fixed in two ways:

  • Using LoggerLevel.Error to minimize logs.
  • skip .turnOn() when tracing is disabled or modify rust enum in matrix-rust-sdk-crypto-wasm/src/tracing.rs to include an off level.

@Srayash
Copy link
Author

Srayash commented Oct 19, 2024

Changes needed to fix the build

Hi @andybalaam ,

I have made the requested changes by skipping .turnOn() when tracing is disabled

Please let me know if further adjustments are needed or if everything looks good now.

Thanks!

@Srayash Srayash requested a review from andybalaam October 19, 2024 13:45
@andybalaam
Copy link
Member

I have made the requested changes by skipping .turnOn() when tracing is disabled

Sounds to me like the right change.

Please let me know if further adjustments are needed or if everything looks good now.

I just kicked off the tests but I am strongly guessing they will fail after your latest change.

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

Tests fail because they test for the old behaviour before the recent change.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

disabling logging altogether seems like a very bad idea. How will you diagnose any issues that occur?

Comment on lines +105 to +109
if (tracingEnabled) {
new RustSdkCryptoJs.Tracing(RustSdkCryptoJs.LoggerLevel.Debug).turnOn();
} else {
// Do not initialize tracing when disabled
}
Copy link
Member

Choose a reason for hiding this comment

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

the problem with this is that incorrectly gives the impression that tracing can be enabled or disabled at the level of an individual instance of RustCrypto.

For example: if I call initRustCrypto({tracingEnabled: true}), and then later, for a different MatrixClient instance, call initRustCrypto({tracingEnabled: false}), tracing will be enabled for the second instance despite tracngEnabled being set to false.

What we really need is to do the work in matrix-sdk-crypto-wasm to connect the logging from the rust tracing system to logger, so that it can be correctly enabled or disabled via the js-sdk's logging API.

@Srayash Srayash closed this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Enhancement Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option for MatrixClient.initRustCrypto() to disable tracing
3 participants