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

🎁 octavia-cli: add telemetry #11896

Merged
merged 10 commits into from
Apr 14, 2022
Merged

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Apr 11, 2022

What

We want to add telemetry to octavia-cli in order to track the adoption and the tool and detect common errors.

How

  • Use Segment's python package: I created two Segment source and write keys (octavia-cli prod and dev)
  • Track usage of commands by defining a custom OctaviaCommand subclass of click's Command. I patched the parent's make_context and invoke methods to collect and send telemetry in case of success or error.
  • Set the user agent of octavia-cli in case this could help measure the traffic sent to the API from the CLI
  • Update the README to explain what data is collected and how to disable telemetry.

Recommended reading order

  1. octavia-cli/octavia_cli/telemetry.py
  2. octavia-cli/octavia_cli/base_commands.py
  3. octavia-cli/octavia_cli/entrypoint.py

Other changes are made to make the commands use the custom OctaviaCommand.
Feel free to read the unit tests too!

🚨 User Impact 🚨

This should be transparent for users

@alafanechere alafanechere force-pushed the augustin/octavia-cli/track branch from c629d04 to 0e7a5ae Compare April 12, 2022 13:53
@alafanechere alafanechere marked this pull request as ready for review April 12, 2022 14:00
@alafanechere alafanechere self-assigned this Apr 12, 2022
user_id = ctx.obj.get("WORKSPACE_ID")
anonymous_id = None if user_id else str(uuid.uuid1())

segment_context = {"app": {"name": "octavia-cli", "version": ctx.obj.get("OCTAVIA_VERSION")}}
Copy link
Contributor

Choose a reason for hiding this comment

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

tracking the AIRBYTE_VERSION of the api that is being interacted with could also help, but we'd need an API to know what version the server is running?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like there's no endpoint in the API that gives the airbyte version information 🤦

* Success or failure of the command run and the error type.
* The workspace id. It is unique to each Airbyte instance, but we can't match it to a username or email address.

You can disable telemetry by setting the `OCTAVIA_ENABLE_TELEMETRY` environment to `false` or using the `--disable-telemetry` flag.
Copy link
Contributor

@ChristopheDuong ChristopheDuong Apr 12, 2022

Choose a reason for hiding this comment

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

Maybe the "default" telemetry behavior can also follow the boolean for tracking or not on the airbyte instance too?

Copy link
Contributor Author

@alafanechere alafanechere Apr 12, 2022

Choose a reason for hiding this comment

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

The boolean for tracking or not is the TRACKING_STRATEGY env var. Unfortunately, the API only returns the anonymousDataCollection field which does not mean the user has turned off analytics on their instance, it just mean they want to avoid mapping their workplace id to their email. Our default is the "anonymous data collection" as we don't handle emails.

@alafanechere alafanechere temporarily deployed to more-secrets April 12, 2022 15:14 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets April 12, 2022 15:14 Inactive
Comment on lines 1212 to 1220
public void testUpdateConnectionWhenWorkflowUnreachable() throws Exception {
// This test only covers the specific behavior of updating a connection that does not have an underlying temporal workflow.
// This case only occurs with the new scheduler, so the entire test is inside the feature flag conditional.
// Also, this test doesn't verify correctness of the schedule update applied, as adding the ability to query a workflow for its current
// schedule is out of scope for the issue (https://github.com/airbytehq/airbyte/issues/11215). This test just ensures that the underlying workflow
// This test only covers the specific behavior of updating a connection that does not have an
// underlying temporal workflow.
// This case only occurs with the new scheduler, so the entire test is inside the feature flag
// conditional.
// Also, this test doesn't verify correctness of the schedule update applied, as adding the ability
// to query a workflow for its current
// schedule is out of scope for the issue (https://github.com/airbytehq/airbyte/issues/11215). This
// test just ensures that the underlying workflow
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 was not formatted on master and broke the build.

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Had several small comments but I don't think any of them are blocking. Otherwise LGTM

This CLI has some telemetry tooling to send Airbyte some data about the usage of this tool.
We use this data to measure the tool's adoption and detect common errors users encounter to improve it.
The telemetry sends data about:
* Which command was run (not the arguments or options used).
Copy link
Contributor

Choose a reason for hiding this comment

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

(not the arguments or options used)

Just curious, why are we not tracking the arguments/options used in a request? Is this because we expect the arguments to be different for each user, so it will not be helpful in the aggregate user tracking we want to get out of this?

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 wanted to add the least amount of user data to this telemetry. As arguments or options are free user inputs I did not want to risk exposing sensitive information in the telemetry. I'm also thinking that to grasp which resources are managed with Octavia, we can rely on the existing telemetry from the core platform. This is why I added a dedicated user agent for octavia. We can find Octavia related traffic if the user agent is available in the API telemetry. We can also join the workspace id from octavia telemetry with the workpace id from the API telemetry to get a bit more insights.
I wanted to focus Octavia telemetry on getting a sense of which commands are used, which commands cause errors, that's all.

@alafanechere alafanechere merged commit 0964c83 into master Apr 14, 2022
@alafanechere alafanechere deleted the augustin/octavia-cli/track branch April 14, 2022 10:11
suhomud pushed a commit that referenced this pull request May 23, 2022
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.

3 participants