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

feat: Add auto-logging feature #1274

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

feat: Add auto-logging feature #1274

wants to merge 15 commits into from

Conversation

ptang-nr
Copy link
Contributor

The auto-logging feature builds on top of the current API calls log and wrapLogger. The api calls continue to provide a way to add custom attributes as needed. Otherwise, customers may simply configure browser logs (on/off, logging level, and sampling rates), which will capture logging statements from the browser console across a given session automatically.

Overview

This PR includes work that:

  • wraps the various logging methods of the console
  • aggregates logging events according to the log flag received from rum call to BCS
  • persists logging mode across active session and will auto-disable upon session expiration after 4 hours or session inactivity after 30 minutes.

Related Issue(s)

https://new-relic.atlassian.net/browse/NR-323591
https://new-relic.atlassian.net/browse/NR-323597
https://new-relic.atlassian.net/browse/NR-341932

Testing

  • Extended the existing e2e tests for logging harvests:

    • pre-load
    • post-load
    • harvests that are too large
    • harvest early
  • Extended existing logging aggregate unit and e2e tests around handling the flag. Includes tests for each logging mode to ensure log messages of equal or higher levels are collected. For example, if the log flag = 3 (INFO), then collect console.error, console.warn, console.info, and console.log events.

  • Extended existing tests to ensure no harvests when rum flag = 0 and events are drained.

Copy link

github-actions bot commented Dec 11, 2024

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 29.75 kB / 10.79 kB (gzip) 29.81 kB / 10.81 kB (gzip) 0.19% / 0.23% (gzip)
lite async-chunk 52.46 kB / 17.03 kB (gzip) 52.49 kB / 17.04 kB (gzip) 0.06% / 0.08% (gzip)
pro loader 51.4 kB / 17.74 kB (gzip) 51.84 kB / 17.85 kB (gzip) 0.86% / 0.61% (gzip)
pro async-chunk 99.29 kB / 30.32 kB (gzip) 100.5 kB / 30.67 kB (gzip) 1.22% / 1.15% (gzip)
spa loader 59.02 kB / 20.07 kB (gzip) 59.46 kB / 20.18 kB (gzip) 0.75% / 0.55% (gzip)
spa async-chunk 114 kB / 34.66 kB (gzip) 115.22 kB / 35 kB (gzip) 1.07% / 0.98% (gzip)

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 70.73171% with 12 lines in your changes missing coverage. Please review.

Project coverage is 88.48%. Comparing base (c22f253) to head (7b64d2f).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/features/logging/aggregate/index.js 64.51% 10 Missing and 1 partial ⚠️
src/features/session_replay/aggregate/index.js 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1274      +/-   ##
==========================================
- Coverage   88.54%   88.48%   -0.07%     
==========================================
  Files         170      170              
  Lines        7325     7362      +37     
  Branches     1480     1495      +15     
==========================================
+ Hits         6486     6514      +28     
- Misses        723      731       +8     
- Partials      116      117       +1     
Flag Coverage Δ
unit-tests 79.60% <70.73%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

newrelic.wrapLogger(console, 'info', {customAttributes: {wrappedFn: 'console.info'}, level: 'info'})
newrelic.wrapLogger(console, 'debug', {customAttributes: {wrappedFn: 'console.debug'}, level: 'debug'})
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was removed for the experimental publish to staging

Copy link

github-actions bot commented Dec 11, 2024

Static Badge

Last ran on December 16, 2024 19:32:27 CST
Checking merge of (6053f42) into main (c770ad0)

Copy link
Contributor

Choose a reason for hiding this comment

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

Since session isn't applicable to all (or even a majority) of the features, I think you should leave it out of the base class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(ah, just saw this EOD yesterday) - when i introduced it at the time, I hadn't the association that aggregate-base should only contain code relevant to all/majority of features, just methods/attrs that could be common and it's up to specific features whether they use 'em 🤔

I can move the logic back into the feat agg constructors. Can't really think of anywhere else or anything i want to introduce yet. Lmk if you have other thoughts!

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