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

[SDK-3975] Strip logging from modular variant of the SDK #1536

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Dec 6, 2023

Note: This PR is based on top of #1581; please review that one first.

In order to reduce bundle size further, we’ve decided to strip all logging from the modular variant of the SDK, except for errors and certain network events. See commit messages for more details.

I'd welcome feedback on whether the logs that I’ve chosen to preserve (i.e. the calls to logActionNoStrip) are the right ones.

Resolves #1526.

@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 6, 2023 19:32 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/bundle-report December 6, 2023 19:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/typedoc December 6, 2023 19:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 6, 2023 19:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 6, 2023 19:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/bundle-report December 6, 2023 19:35 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/typedoc December 6, 2023 19:35 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 6, 2023 19:40 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 6, 2023 19:40 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/bundle-report December 6, 2023 19:41 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/typedoc December 6, 2023 19:41 Inactive
@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review December 6, 2023 20:02
Copy link
Contributor

@VeskeR VeskeR left a comment

Choose a reason for hiding this comment

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

I really like the solution of actually building the syntax tree using babel, and then stripping the logs based on found expression.
This is way more reliable than relying on regular expressions to parse strings to find lines of code that are related to the Logger calls - our initial idea.

Also check my code comments

Gruntfile.js Outdated Show resolved Hide resolved
Gruntfile.js Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 8, 2023 13:13 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/typedoc December 8, 2023 13:14 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/bundle-report December 8, 2023 13:14 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 8, 2023 13:16 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/bundle-report December 8, 2023 13:17 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/typedoc December 8, 2023 13:17 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/features December 8, 2023 13:18 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1536/bundle-report December 8, 2023 13:19 Inactive
Copy link
Contributor

@VeskeR VeskeR left a comment

Choose a reason for hiding this comment

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

LGTM!

Let's wait for @owenpearson to take a look at logs that are preserved.

Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

I think we ought to add some logging to the platform http clients in order to properly add tracing for http requests - there are a few places where we call methods directly on the http client rather than using the Resource methods so currently this wont catch anything (same kinda goes for protocol.send because we call transport.send directly in one place but that will change once we remove upgrade so it's fine to keep it as is).

Need this in order to use esbuild plugins.
In order to reduce bundle size further, we’ve decided to strip all
logging from the modular variant of the SDK, except for errors and
certain network events. (We also considered providing a separate
tree-shakable module with all of this logging code so that a user of the
modular variant of the library can opt in to it, but decided against it
for now; we might add it in later. This does mean that there is
currently no version of the SDK that allows you to use both deltas and
verbose logging on web.)

I couldn’t find any out-of-the-box esbuild functionality that let us do
this. The only stuff I could find related to stripping code was:

- the `pure` option, but that code only gets stripped if you minify the
  code (and even in that case I couldn’t actually get it to be stripped,
  perhaps would have been able to with further trying though), but
  minifying our generated modules bundle causes the bundle size of those
  who use it (as tested by our modulereport script) to increase
  considerably (for reasons I’m not sure of)

- the `drop` option, but that only lets you remove calls to `console` or
  `debugger`

So instead I’ve implemented it as an esbuild plugin.

Resolves #1526.
@lawrence-forooghian
Copy link
Collaborator Author

lawrence-forooghian commented Jan 18, 2024

I think we ought to add some logging to the platform http clients in order to properly add tracing for http requests

Sure — I've done this in #1581, on top of which the current PR is now based.

@lawrence-forooghian
Copy link
Collaborator Author

@VeskeR would you mind resolving your comments please?

@VeskeR
Copy link
Contributor

VeskeR commented Jan 19, 2024

@lawrence-forooghian Resolved

Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

looks good now 👍

Base automatically changed from improve-http-logging to integration/v2 January 24, 2024 08:48
@lawrence-forooghian lawrence-forooghian merged commit 4c1be01 into integration/v2 Jan 24, 2024
12 checks passed
@lawrence-forooghian lawrence-forooghian deleted the 1526-strip-logging branch January 24, 2024 08:49
@VeskeR VeskeR mentioned this pull request Mar 1, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants