-
Notifications
You must be signed in to change notification settings - Fork 668
DYN-6030 Log Heartbeat events to log active/idle states #14684
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
Conversation
| { | ||
| serviceInitialized.Wait(); | ||
|
|
||
| lock (trackEventLockObj) |
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.
hmm
@pinzart90 @BogdanZavu - What is this lock protecting?
ReportingAnalytics? Is that really going to be changing?
Because this task gets run when a user clicks the left mouse button it seems we're going to kick off a bunch of tasks that attempt to acquire this lock and wait for each other until these API calls return... is the lock really needed in this case?
Do we know how long these API calls take @zeusongit ?
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.
In debug build, it takes less than 1000 ticks (on average). First call was 3000, all proceeding calls were less than 500.
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.
ReportingAnalytics? Is that really going to be changing? - mostlikely not but it is safer imo to have it like this. It does not buy us anything if it is outside, it will only exposes us to risk now and in the future if the implementation changes.
The lock is protecting from concurrent access into ADP api. In theory that is noted as being thread safe but there were reports with relatively simple use cases where surprisingly it is not. So to be on the safe side we have this lock.
| using System.Linq; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Autodesk.ADPDesktopSDK; |
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.
Where is this namespace coming from?
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.
Was coming from AdpSDKCSharpWrapper.dll
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.
If we are ok with bleeding AdpSDKCSharpWrapper types directly in Dynamo, then makes me wonder why we need an entire Analytics project in between Dynamo and AdpSDKCSharpWrapper. Maybe it made sense when we had multiple analytics providers...but now.
I think it would make it somewhat simpler to consume if we referenced the binary directly in Dynamo and gave up on all the complicated logic of the Analytics.Core. Of course AdpSDKCSharpWrapper is an internal nuget package, so we would have to handle its distribution directly in Dynamo.
Of course if we think we might get into a situation with multiple analytics providers again, then I suggest we keep layer of separation intact
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 see what was going on. When consuming the Analytics nuget pacakge, we now have access to the AdpSDKCSharpWrapper.dll at compile time
So any dev writing code could potentially access types directly from that assembly
There are ways to avoid this, like removing the adpsdk binrary from libs, and adding a build.props with a copy target.
|
Just curious overall why do we need to track this ? What are we looking for or what decision can we made based on this data to improve Dynamo ? |
| public virtual IAnalyticsSession Session { get; private set; } | ||
|
|
||
| private DateTime LastMachineHBLogTime; | ||
| private DateTime LastUserHBLogTime; |
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.
since I don't see these fields set anywhere initially, won't they always be null and no events will ever be sent?
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.
DateTime types are initiated with a default value just like booleans
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.
ah it's a struct
| Export | ||
| } | ||
|
|
||
| public enum HeartBeatType |
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.
does this need to be public?
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 guess it does if the method is public?
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
I'm curious about the premise of using this data as well because I feel that impacts what "active" means. |
@mjkkirschner There is a separate identifier for when the machine is active/idle, it will log exactly the cases you mentioned, i.e the machine is active but the user is or maybe idle. |
|
Re-triggered the Analytics build, after the nugets are generated build should pass. |
UI Smoke TestsTest: success. 2 passed, 0 failed. |
UI Smoke TestsTest: success. 2 passed, 0 failed. |
| /// as the API expects a call every 5 minutes, to mark the user/machine active. | ||
| /// </summary> | ||
| /// <param name="activityType">Value must be either Machine or User. If no value is provided the API will default to user activity type.</param> | ||
| public void TrackActivityStatus(string activityType) |
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.
do we expect this API to be used by externally ?
shouldn;t this be internal to dynamo ?
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.
It is declared in IAnalyticsClient interface
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/interfaces#:~:text=To%20implement%20an%20interface%20member
|
@zeusongit I think you should add a test to ensure your code does what you think it does and that the behavior does not change. |
@mjkkirschner I can add track activity status to the current analytics test, but I don't think the current Moq implementation of the Analytics will be able to completely test the functionality of this method, for e.g how to test that it will send off 1 log for each activity type in a 4 minute period. |
you should make your code testable - you can have the timeout be a parameter and set it lower for the test. |
UI Smoke TestsTest: success. 2 passed, 0 failed. |
UI Smoke TestsTest: success. 2 passed, 0 failed. |
UI Smoke TestsTest: success. 2 passed, 0 failed. |
UI Smoke TestsTest: success. 2 passed, 0 failed. |
@mjkkirschner parametrization is not a problem here, the problem is to track if the ADP service actually recorded the log, verifying the Moq instance for invocation will not record the desired result. After discussion with the team we have decided to go forward with the current state, and file a separate task to improve the machine active/idle time tracking in the future release. |
* Fix PostDiff job * log heartbeat * Optimize logging and add mouse and key press events log * Update DynamoAnalyticsClient.cs * add machine tracking status * comments * Update Analytics nuget * add to test
Purpose
https://jira.autodesk.com/browse/DYN-6030
Add heartbeat ADP API to log active/idle user state.
This PR build will fail since we need the analytics PR first:https://git.autodesk.com/Dynamo/Analytics.NET/pull/70
Declarations
Check these if you believe they are true
*.resxfilesRelease Notes
Reviewers