Refactor command tracking event/context to be initialized earlier
See original GitHub issueTo get things out the door in hurry, the current (although not actually merged yet as of this writing) command tracking events and context are initialized within the cli implementations of those commands. e.g.:
But we could (should?) initialize it further up the stack when click is setting up, maybe https://github.com/meltano/meltano/blob/762a2592c5da95fa6b1e91aa3c20d79725949a66/src/meltano/cli/cli.py#L32 ? Then we could also add the global opts like --log-level
to the tracking context.
The initialized tracker with appropriate tracking context could then be embedded in the click context (context
is suddenly a super loaded term for us), and down stream we could pull the tracker from the click context:
@click.option("--some-option")
@click.pass_context
def some_cli_command(ctx, some_option):
tracker = ctx.obj["tracker"]
Related work items
Noted this related issue may be solved at the same time (or not):
If resolved, we can close the other at the same time. If not, we’ll re-raise/re-prioritize that after this closes.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:10 (9 by maintainers)
I’ll note that the simplification isn’t just for the benefit of us Meltano core dev who want “cleaner” code. Any external contributor should be able to add to or edit the Meltano CLI without thinking about telemetry. Making it automatic via a decorator would enable that.
@aaronsteers @WillDaSilva Ok I have a proposal of how we might do this up in https://github.com/meltano/meltano/pull/6260, It’s still a Draft because it’s just a proposal at this point. Lots of details in the PR body though and example usage in our 3 most common current scenarios. Please let me know what you think over on the PR, and we’ll iterate from there.
@pnadolny13 have one ask for you in the PR. On what you’d like the schema to look like for the cli params I collect. Currently, I’m just using a dict of the keys/values, but could do something more strict if you’d prefer.