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

[Wallet] Adding time metrics to sync and tx events, also new events. #3810

Closed
wants to merge 23 commits into from

Conversation

jio-gl
Copy link
Contributor

@jio-gl jio-gl commented May 13, 2020

Description

Adding time elapsed to Sync Event and Tx Events.

Tested

Manually on Debug console.

Related issued

Part of #3653

Backwards compatibility

Some event names where changed, this is not compatible with existing data on Analytics.

@jio-gl jio-gl self-assigned this May 13, 2020
@jio-gl jio-gl changed the title Adding time metrics to some events, new events. Adding time metrics to sync and tx events, also new events. May 13, 2020
Copy link
Contributor

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

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

Good progress and congrats on your first wallet PR!

packages/mobile/src/transactions/saga.ts Outdated Show resolved Hide resolved
packages/mobile/src/transactions/saga.ts Outdated Show resolved Hide resolved
@@ -77,13 +79,17 @@ export function* checkWeb3SyncProgress() {
if (latestBlock && latestBlock.number > 0) {
yield put(completeWeb3Sync(latestBlock.number))
Logger.debug(TAG, 'checkWeb3SyncProgress', 'Sync is complete')
millisecs = Date.now() - initTime
CeloAnalytics.track(CustomEventNames.sync_complete, { millisecs })
Copy link
Contributor

Choose a reason for hiding this comment

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

This method gets called potentially many times throughout the lifetime of the app. We probably don't want to spam out events for each micro-sync right? We should find a different strategy for tracking sync time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do a Moving Average every N micro-sync and then post every M micro-sync. What do you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it now with only one parameter: N = M.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example track() is called on start sync and once every 100 syncs. Mean and spot time elapsed since sync start is reported.

@codecov
Copy link

codecov bot commented May 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@69005a0). Click here to learn what that means.
The diff coverage is 70.17%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3810   +/-   ##
=========================================
  Coverage          ?   75.69%           
=========================================
  Files             ?      303           
  Lines             ?     8855           
  Branches          ?     1106           
=========================================
  Hits              ?     6703           
  Misses            ?     2016           
  Partials          ?      136           
Flag Coverage Δ
#mobile 75.69% <70.17%> (?)
Impacted Files Coverage Δ
packages/mobile/src/transactions/saga.ts 31.57% <11.11%> (ø)
packages/mobile/src/geth/geth.ts 39.47% <54.54%> (ø)
packages/mobile/src/web3/saga.ts 43.75% <60.00%> (ø)
packages/mobile/src/analytics/constants.ts 98.72% <100.00%> (ø)
packages/mobile/src/utils/time.ts 69.09% <100.00%> (ø)
packages/mobile/src/goldToken/reducer.ts 100.00% <0.00%> (ø)
packages/mobile/src/firebase/saga.ts 42.10% <0.00%> (ø)
packages/mobile/src/images/unknown-user-icon.png 100.00% <0.00%> (ø)
packages/mobile/src/transactions/reducer.ts 47.36% <0.00%> (ø)
packages/mobile/src/utils/keyStore.ts 40.00% <0.00%> (ø)
... and 298 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69005a0...3f4e172. Read the comment docs.

@jio-gl jio-gl requested a review from nambrot May 15, 2020 18:42
@jio-gl
Copy link
Contributor Author

jio-gl commented May 18, 2020

For loading geth and sync registering only a few events 1 of 100 and also moving average, for tx still all events.

Jose Orlicki added 2 commits May 18, 2020 10:20
@jmrossy jmrossy changed the title Adding time metrics to sync and tx events, also new events. [Wallet] Adding time metrics to sync and tx events, also new events. May 21, 2020
@@ -75,6 +81,13 @@ export function* checkWeb3SyncProgress() {

const latestBlock: Block = yield call(getLatestBlock)
if (latestBlock && latestBlock.number > 0) {
;[meanMillisecs, trackCount] = trackMeanMillisecs(
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm reading this correctly, this is the only event function we need to use trackMeanMilliseconds for, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okey, CustomEventNames.sync_complete then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okey, perfect -> CustomEventNames.sync_complete

meanMillisecs,
trackCount,
TRACK_EVERY_GETH,
CustomEventNames.geth_failed_genesis_block
Copy link
Contributor

Choose a reason for hiding this comment

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

For these kinds of events - I'm not sure we would expect this to happen very often, so I don't think we really need to call this function, right?

Copy link
Contributor Author

@jio-gl jio-gl May 28, 2020

Choose a reason for hiding this comment

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

Yep, these are more abnormal conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okey, good idea, then only CustomEventNames.sync_complete

packages/mobile/src/utils/time.ts Outdated Show resolved Hide resolved
packages/mobile/src/utils/time.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@tarikbellamine tarikbellamine left a comment

Choose a reason for hiding this comment

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

Nice work! Left a couple of comments. It seems like you are mostly tracking duration with your timers but FYI we have timestamps included by default and can calculate the duration between any two events by subtracting the timestamps.

Also worth nothing that we have a trackSubEvents method that allows easy grouping of related events and will track duration between subEvents for us.

@jio-gl
Copy link
Contributor Author

jio-gl commented Jun 17, 2020

Nice work! Left a couple of comments. It seems like you are mostly tracking duration with your timers but FYI we have timestamps included by default and can calculate the duration between any two events by subtracting the timestamps.

Also worth nothing that we have a trackSubEvents method that allows easy grouping of related events and will track duration between subEvents for us.

I am measuring the time with regard to the init of a task, is not between two events. I am only submitting one event per task.

const latestBlock: Block = yield call(getLatestBlock)
if (latestBlock && latestBlock.number > 0) {
yield put(completeWeb3Sync(latestBlock.number))
web3SyncAnalyticsTracker.log(syncStartTime)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like web3SyncAnalyticsTracker is only used here, so the data is never submitted. Would it be possible to just remove it and use the existing CeloAnalytics?

@tarikbellamine
Copy link
Contributor

tarikbellamine commented Jun 26, 2020

@timmoreton, @joigno and I have done some work on geth analytics instrumentation but it recently occurred to me that this is probably a subset of what you are working on

@aaronmgdr aaronmgdr deleted the jose/perf-analytics branch December 16, 2021 23:14
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.

5 participants