-
Notifications
You must be signed in to change notification settings - Fork 142
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
🐛 [RUM-2720] Send logs without session id when session inactive #2578
🐛 [RUM-2720] Send logs without session id when session inactive #2578
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2578 +/- ##
=======================================
Coverage 93.31% 93.32%
=======================================
Files 241 242 +1
Lines 7062 7069 +7
Branches 1561 1567 +6
=======================================
+ Hits 6590 6597 +7
Misses 472 472 ☔ View full report in Codecov by Sentry. |
8c549b5
to
4a5df21
Compare
/to-staging |
🚂 Branch Integration: starting soon, merge in < 8m Commit 4a5df21851 will soon be integrated into staging-05. This build is going to start soon! (estimated merge in less than 8m) Use |
🚨 Branch Integration: The build pipeline was cancelled for this merge request Build pipeline was cancelled for cb25103 If you think this is a mistake, you can re-add your pull request to the queue! If you need support, contact us on Slack #ci-interfaces with those details! |
5ca67b4
to
6e13af9
Compare
- Send logs when a session is expired - Only set session id when the session is active
6e13af9
to
2e162b5
Compare
Bundles Sizes Evolution
🚀 CPU Performance
|
…hout-session-id-when-session-inactive
/to-staging |
🚂 Branch Integration: starting soon, merge in < 9m Commit f1c07e04b4 will soon be integrated into staging-20. This build is going to start soon! (estimated merge in less than 9m) Use |
🚂 Branch Integration: This commit was successfully integrated Commit f1c07e04b4 has been merged into staging-20 in merge commit 4e866dcbea. Check out the triggered pipeline on Gitlab 🦊 |
@@ -19,6 +19,7 @@ export interface LogsInitConfiguration extends InitConfiguration { | |||
forwardErrorsToLogs?: boolean | undefined | |||
forwardConsoleLogs?: ConsoleApiName[] | 'all' | undefined | |||
forwardReports?: RawReportType[] | 'all' | undefined | |||
sendLogsAfterSessionExpiration?: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: Could be nice to add a comment: // TODO next major: remove this option and make it the default behaviour
/to-staging |
🚂 Branch Integration: starting soon, merge in < 9m Commit 3782d12e3c will soon be integrated into staging-20. This build is going to start soon! (estimated merge in less than 9m) Use |
🚂 Branch Integration: This commit was successfully integrated Commit 3782d12e3c has been merged into staging-20 in merge commit fda0dd1e82. Check out the triggered pipeline on Gitlab 🦊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see there is three ways of getting inactive sessions:
- in
valueHistory
, there is theAFTER_ENTRY_START
predicate - in
sessionManager
, there is a different methodfindInactiveOrExpiredSession
- in
logsSessionManager
, there is a{ returnExpired }
option argument.
I would expect to use the same for all three. I like the option object, but not so much the "expired" name, as we already use "active", I think we should use "inactive".
So my suggestion:
- in
valueHistory
, havefind(startTime, { returnInactive })
- in
sessionManager
, introduce afindSession(startTime, { returnInactive })
, that handles both cases (remove otherfind*Session
methods) - in
logsSessionManager
, havefindTrackedSession(startTime, { returnInactive })
(returnInactive
should default to false
in valueHistory
, and you can just pass the options down without worrying about the default in other places)
handleLog({ status: StatusType.info, message: 'message 1' }, logger) | ||
|
||
// expire session | ||
setCookie(SESSION_STORE_KEY, 'isExpired=1', ONE_MINUTE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥜 nitpick: this should be in a test helper, as we're doing it in many places
packages/logs/src/domain/assembly.ts
Outdated
@@ -35,7 +37,7 @@ export function startLogsAssembly( | |||
const log = combine( | |||
{ | |||
service: configuration.service, | |||
session_id: session.id, | |||
session_id: session.isActiveAt(startTime) ? session.id : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 suggestion: I think isActiveAt
complicates things quite a bit. It might be simpler to just call findTrackedSession
multiple times:
const session = sessionManager.findTrackedSession(startTime)
if (
!session &&
(!configuration.sendLogsAfterSessionExpiration || !sessionManager.findTrackedSession(startTime, { returnInactive: true }))
) {
return
}
// and then
session_id: session?.id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! It removes the needs to add endTime
to SessionContext
. I like it 👍
Motivation
Do not drop logs when session inactive
⚠ it's worth reviewing commit by commit
Changes
Testing
I have gone over the contributing documentation.