Skip to content

Conversation

@mokagio
Copy link
Contributor

@mokagio mokagio commented Oct 11, 2022

Description

This PR aims to enable performance monitoring, the concrete implementation of which lives in Tracks and is currently implemented via Sentry, behind feature flags.

When I started working on this, I was under the impression WooCommerce iOS already had support for remote feature flags, but that doesn't seem to be the case. I must have applied my iOS bias to the conversations I had about remote feature flags, not realizing they were about the Android app.

I'm leaving this PR here to pick back up once we'll have support for remote feature flag. Or once someone tells me I got it wrong and it was there all along.

I used the 11.3 milestone for this PR. It's the future-most milestone at the time of creating the PR.

Update: Speaking with @jkmassel, we decided to get this PR to a ready-to-merge state, where all the logic is available but off, ready to build on top of once we'll be ready to tap into the remote feature toggles.

Testing instructions

Download the installable build, then visit the Sentry page to verify performance events from your device have been received.

Screen Shot 2022-10-24 at 3 44 23 pm

If instead you run the app from Xcode, you should see no events.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@mokagio mokagio added this to the 11.3 milestone Oct 11, 2022
@mokagio mokagio added category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. status: feature-flagged Behind a feature flag. Milestone is not strongly held. labels Oct 11, 2022
Comment on lines 42 to 51
case .performanceMonitoring,
.performanceMonitoringCoreData,
.performanceMonitoringFileIO,
.performanceMonitoringNetworking,
.performanceMonitoringViewController,
.performanceMonitoringUserInteraction:
return buildConfig != .appStore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case we decide to land this PR before we have support for remote feature toggles: Do not collect metrics in production.

This seems counterintuitive because production is exactly where we'd like to monitor performance. But, I think we ought to first see this in action in a test environment.

Comment on lines 87 to 106
// This flags are not transient. That is, they are not here to help us rollout a feature,
// but to serve a safety switches to granularly turn off performance monitoring if it looks
// like we are consuming too many events.
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 will make more sense once the feature toggles will be configurable remotely 😅

@mokagio
Copy link
Contributor Author

mokagio commented Oct 11, 2022

@jkmassel @crazytonyli despite this being in draft, I'd appreciate your input on the implementation details that are unrelated to where the FeatureFlag values come from.

One thing that I'm unsure at the moment, however, is the timing of the initialization: Do we wait to instantiate the Tracks stack till we have fetched the feature flags? Or, should we implement a way to update the configuration once new flags are received?

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 11, 2022

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr7831-02d928c on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@mokagio mokagio force-pushed the mokagio/performance-monitoring branch from 37198fa to 1d1f3a2 Compare October 24, 2022 03:34
Comment on lines +147 to +148
// FIXME: Is there a way to control this via feature flags?
sampler: { 0.1 },
Copy link
Contributor Author

@mokagio mokagio Oct 24, 2022

Choose a reason for hiding this comment

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

As long as our feature toggles are Bool only, the only way I can think to configure the sampler rate from the app is to have .performanceMonitoringSampleRateTenPercent, .performanceMonitoringSampleRateTwentyPercent, etc. and a method to compute the numeric value to use here based on a rule such as "use the value corresponding to the highest feature flag enabled".

Eg.

performanceMonitoringSampleRateTenPercent = true
performanceMonitoringSampleRateTwentyPercent = false
performanceMonitoringSampleRateThirtyPercent = true

// => sample rate = 0.3

This sounds like a lot of feature toggles and something it would be easy to get wrong because of how easy it is to forget about updating all of the toggles.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it would be useful to have a remote config for this sample rate, so that we can adjust it in production environment if we find there are too many events sent to Sentry and we have to pay unnecessary cost for it. But as a local configuration though, I feel like it's almost not worth the effort 😿

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and something it would be easy to get wrong because of how easy it is to forget about updating all of the toggles.

My assessment on the risks of using a number of feature toggles to compute the sample rate might be greatly reduced once @hannahtinkler's feature toggles ship.

In particular, since the new feature toggles will be described in code, I can see a reverse of the computation logic described here in place where we give the backend a rate and it decides which toggles to serve as on and which off.

@mokagio mokagio modified the milestones: 11.3, 11.0 Oct 24, 2022
@mokagio mokagio requested a review from jkmassel October 24, 2022 03:46
@mokagio mokagio force-pushed the mokagio/performance-monitoring branch from 1d1f3a2 to 9d3a6d4 Compare October 24, 2022 03:46
@mokagio mokagio requested a review from crazytonyli October 24, 2022 03:46
@mokagio mokagio changed the title On Hold – Enable performance monitoring behind feature flags Add performance monitoring configuration behind feature flags – Off by default Oct 24, 2022
@mokagio mokagio marked this pull request as ready for review October 24, 2022 04:37
@mokagio mokagio modified the milestones: 11.0 ❄️, 11.1 Oct 31, 2022
Comment on lines +147 to +148
// FIXME: Is there a way to control this via feature flags?
sampler: { 0.1 },
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it would be useful to have a remote config for this sample rate, so that we can adjust it in production environment if we find there are too many events sent to Sentry and we have to pay unnecessary cost for it. But as a local configuration though, I feel like it's almost not worth the effort 😿

@mokagio mokagio force-pushed the mokagio/performance-monitoring branch from 9d3a6d4 to 02d928c Compare November 1, 2022 18:03
@mokagio mokagio enabled auto-merge November 1, 2022 18:04
@mokagio mokagio merged commit fb7325e into trunk Nov 1, 2022
@mokagio mokagio deleted the mokagio/performance-monitoring branch November 1, 2022 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. status: feature-flagged Behind a feature flag. Milestone is not strongly held.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants