GitHub
09/05/2024, 5:40 PMinstall_plugins to meltano.core.plugin_install_service
Pull request opened by edgarrmondragon
Description
This lets us eliminate one dependency on meltano.cli in meltano.core, though there's still
meltano/src/meltano/core/tracking/tracker.py
Lines 520 to 569 in</meltano/meltano/commit/4efb91d68bb8e5c2364ea7ae2f032a937959d3f2|4efb91d>
| def setup_exit_event(self) -> None: |
| ----------------------------------------------------------------------------- |
| """If not already done, register the atexit handler to fire the exit event. |
| |
| This method also provides this tracker instance to the CLI module for |
| it to fire an exit event immediately before the CLI exits. The atexit |
| handler is used only as a fallback. |
| """ |
| from meltano import cli |
| |
| if cli.atexit_handler_registered: |
| return |
| |
| cli.atexit_handler_registered = True |
| |
| # Provide meltano.cli with this tracker to track the exit event with |
| # more context. |
| cli.exit_event_tracker = self |
| |
| # As a fallback, use atexit to help ensure the exit event is sent. |
| atexit.register(self.track_exit_event) |
| |
| def track_exit_event(self) -> None: |
| """Fire exit event.""" |
| from meltano import cli |
| |
| if cli.exit_code_reported: |
| return |
| cli.exit_code_reported = True |
| |
| start_time = datetime.fromtimestamp(Process().create_time(), tz=timezone.utc) |
| |
| # This is the reported "end time" for this process, though in reality |
| # the process will end a short time after this time as it takes time |
| # to emit the event. |
| now = datetime.now(timezone.utc) |
| |
| self.track_unstruct_event( |
| SelfDescribingJson( |
| ExitEventSchema.url, |
| { |
| "exit_code": cli.exit_code, |
| "exit_timestamp": f"{now.isoformat()}", |
| "process_duration_microseconds": int( |
| (now - start_time).total_seconds() * MICROSECONDS_PER_SECOND, |
| ), |
| }, |
| ), |
| ) |
| self.snowplow_tracker.flush() |
| atexit.unregister(self.track_exit_event) |
which I'm not sure yet how to decouple.
Related Issues
• Closes #XXXX
meltano/meltano
✅ All checks have passed
30/30 successful checksGitHub
09/05/2024, 5:40 PMinstall_plugins to meltano.core.plugin_install_service
Pull request ready for review by edgarrmondragon
meltano/meltanoGitHub
09/05/2024, 8:26 PM