aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Make minor tweaks before launch

Open Leo10Gama opened this issue 2 years ago • 0 comments

Which issue(s) does this change fix?

N/A

Why is this change necessary?

There were a few things I wasn't happy with reflecting on some of my previous code, and they were too small to fit into PRs on their own. Thus, they've been delegated to this PR, which has many tiny adjustments and tweaks, outlined below in order of significance.

How does it address the issue?

  • EventTracker.send_events now executes on a thread! Previously, this logic was only implemented when the function was called at capacity. Now, it's the default!
  • EventTracker now stores session_id locally. This fixes a bug I was only recently made aware of, where Events sent in a thread did not contain the session ID, thus preventing us from linking the data. With the new implementation, the session ID is appended to the Metric before it is sent out.
  • The decorators on sam sync are rearranged (namely, track_command and track_long_event have swapped places). This will prevent one send_events from being called, then the "end event" being added, and then one more send_events being called.
    • This reasoning has also been added to the docstring for the track_long_event decorator.
  • The attribute EventType._events has been renamed to EventType._event_values. This not only prevents ambiguity, but also prevents confusion with EventTracker._events.
  • Added a docstring to EventTracker.get_tracked_events method.
  • Added a comment beside EventType._event_values to provide explanation as to what the value represents.
  • Added comments in the track_long_event decorator to provide clarity on the process of the method.

What side effects does this change have?

Aside from some readability improvements within my code, the only notable side effect is the EventTracker.send_events executing on a separate thread always.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • [x] Add input/output type hints to new functions/methods
  • [ ] Write design document if needed (Do I need to write a design document?)
  • [x] Write/update unit tests
  • [x] Write/update integration tests
  • [ ] Write/update functional tests if needed
  • [x] make pr passes
  • [ ] make update-reproducible-reqs if dependencies were changed
  • [ ] Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Leo10Gama avatar Aug 10 '22 22:08 Leo10Gama