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

Browser-side analytics services: use core logger #184520

Merged

Conversation

pgayvallet
Copy link
Contributor

Summary

When we implemented the browser-side analytics service, browser-side logger wasn't a thing yet, so we had to implement a custom one. This PR addresses that, by now properly using core's logger.

Direct upside is that those messages:

this.initContext.logger.debug<EventDebugLogMeta>(`Report event "${eventType}"`, {
ebt_event: event,
});

using the debug level will now be silent by default, unless the developer explicitly sets logging.browser.root.level to INFO or superior.

@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet pgayvallet added chore Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.15.0 release_note:skip Skip the PR/issue when compiling release notes labels May 30, 2024
@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet pgayvallet changed the title Browser-side analytics service: use Core logger Browser-side analytics services: use core logger May 30, 2024
@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet
Copy link
Contributor Author

/ci

@pgayvallet pgayvallet marked this pull request as ready for review May 31, 2024 07:13
@pgayvallet pgayvallet requested a review from a team as a code owner May 31, 2024 07:13
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

const report = createUiCounterMetric({ type, appName, eventName, count });
this.log(report);
this.logger.debug(JSON.stringify(report));
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT we can wrap this one under isLevelEnabled, to avoid JSON.stringify() cost when not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call 👍

Copy link
Contributor

@gsoldevila gsoldevila left a comment

Choose a reason for hiding this comment

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

Nice cleanup! 1 NIT

@pgayvallet pgayvallet enabled auto-merge (squash) May 31, 2024 09:44
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 519 518 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 417.3KB 417.0KB -317.0B
kbnUiSharedDeps-srcJs 3.2MB 3.2MB +62.0B
usageCollection 5.0KB 5.0KB +29.0B
total -226.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/analytics 1 0 -1
@kbn/core-analytics-browser-internal 15 8 -7
total -8

Total ESLint disabled count

id before after diff
@kbn/analytics 1 0 -1
@kbn/core-analytics-browser-internal 15 8 -7
total -8

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pgayvallet pgayvallet merged commit 8253d7e into elastic:main May 31, 2024
18 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 31, 2024
pgayvallet added a commit that referenced this pull request Jun 3, 2024
## Summary

Part of #144276
Somewhat related to #184520

Allow to configure level of individual browser-side loggers

**Example:**
```yaml
logging.browser:
    loggers:
       - name: analytics 
         level: debug
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting chore release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants