-
-
Notifications
You must be signed in to change notification settings - Fork 956
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
SAK-50846 Sitestats successive sitestats calculated incorrectly #13230
base: master
Are you sure you want to change the base?
Conversation
@@ -54,6 +58,7 @@ public boolean add(@NonNull Presence presence) { | |||
|
|||
if (records.contains(additialRecord)) { | |||
// Record is already present in list, leave unchanged | |||
log.debug("Record already present: " + additialRecord); |
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.
"Concatenation is expensive, so you want it to happen only when needed. By using {}, slf4j performs the concatenation only if the trace is needed. In production, you may configure the log level to INFO, thus ignoring all debug traces."
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.
Good point Sam! Most of the time debug is disabled.
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 took the opportunity to update the rest of the concatenations in the log.debug statements of the modified files.
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.
this passes the tests locally for me.
just need to fix lombok, slf4j log concatenation.
thanks for the patch
public void setOriginallyEnding(boolean originallyEnding) { | ||
this.originallyEnding = originallyEnding; | ||
} | ||
|
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.
the use of lombok @Data
means these getters and setters are unnecessary
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.
Yes, you can remove the getters, setters. I would change to Boolean
. Though, you will need to replace the use of isOriginallyEnding
with `getOriginallyEnding.
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.
Great work Manu! I left some comments for minor improvements.
|
||
import lombok.NonNull; | ||
|
||
public class PresenceConsolidation { | ||
|
||
|
||
private static final Logger log = LoggerFactory.getLogger(PresenceConsolidation.class); |
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.
Use @Slf4j
instead
|
||
log.debug("currentOpenSessions: {}", currentOpenSessions); | ||
|
||
if (!allUserSitePresences.isEmpty() && allUserSitePresences.get(0).isBeginning() && savedOpenSessions == 0) { |
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.
Is it safe to look just at the first entry, should we check if there is any beginning presence?
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.
actually, that check isn't necessary; I removed it. if there were no open sessions (savedOpenSessions == 0
), with the current logic, we can disregard the saved login start (savedBegin
) since we are no longer dealing with overlapping sessions.
@@ -1669,7 +1735,9 @@ private String parseSiteId(Event e){ | |||
if(contextId != null && contextId.startsWith(sitePrefix)) { | |||
contextId = contextId.substring(sitePrefix.length()); | |||
} | |||
log.debug("Context read from Event.getContext() for event: " + eventId + " - context: " + contextId); | |||
if (eventId == "pres.end" || eventId == "pres.begin") { |
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.
Should we keep this condition or was it just for your testing?
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.
exactly, I removed the condition, thnks
@@ -54,6 +58,7 @@ public boolean add(@NonNull Presence presence) { | |||
|
|||
if (records.contains(additialRecord)) { | |||
// Record is already present in list, leave unchanged | |||
log.debug("Record already present: " + additialRecord); |
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.
log.debug("Record already present: " + additialRecord); | |
log.debug("Record already present: {}", additialRecord); |
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.
Here an example. Please apply this to the other debug logs as well @st-manu
@@ -54,6 +58,7 @@ public boolean add(@NonNull Presence presence) { | |||
|
|||
if (records.contains(additialRecord)) { | |||
// Record is already present in list, leave unchanged | |||
log.debug("Record already present: " + additialRecord); |
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.
Good point Sam! Most of the time debug is disabled.
public void setOriginallyEnding(boolean originallyEnding) { | ||
this.originallyEnding = originallyEnding; | ||
} | ||
|
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.
Yes, you can remove the getters, setters. I would change to Boolean
. Though, you will need to replace the use of isOriginallyEnding
with `getOriginallyEnding.
Please also do a rebase on master |
e762754
to
3c8fb8d
Compare
thank you for your comments, @stetsche and @ottenhoff ! |
3c8fb8d
to
bec94e9
Compare
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.
Just found a little error. Else looking good
@@ -1669,9 +1735,9 @@ private String parseSiteId(Event e){ | |||
if(contextId != null && contextId.startsWith(sitePrefix)) { | |||
contextId = contextId.substring(sitePrefix.length()); | |||
} | |||
log.debug("Context read from Event.getContext() for event: " + eventId + " - context: " + contextId); | |||
log.debug("Context read from Event.getContext() for event: {} - context: ", eventId, contextId); |
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.
Missing placeholder
log.debug("Context read from Event.getContext() for event: {} - context: ", eventId, contextId); | |
log.debug("Context read from Event.getContext() for event: {} - context: {}", eventId, contextId); |
log.debug("k{} savedBegin: {}", key, savedBegin); | ||
log.debug("k{} firstBeginningPresenceBegin: {}", key, firstBeginningPresenceBegin); | ||
log.debug("k{} lastStart: {}", key, lastStart); |
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.
these debug statements should probably be consolidated
bec94e9
to
066220e
Compare
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.
Looking good, thanks @st-manu! Could you do a rebase to be current with master please?
066220e
to
53b368b
Compare
https://sakaiproject.atlassian.net/browse/SAK-50846
Conversion: sakaiproject/sakai-reference#263
If a user is connected when the SiteStats Event Aggregator job is run, the user's previously closed session is merged with the active session.
real time presence
x-----x | x-------|----x
calculation
x--------------------------x