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

Solution: Add telemetry to track metrics #453

Merged
merged 17 commits into from
Sep 11, 2020
Merged

Solution: Add telemetry to track metrics #453

merged 17 commits into from
Sep 11, 2020

Conversation

mrmarcsmith
Copy link
Contributor

@mrmarcsmith mrmarcsmith commented Sep 1, 2020

Implements #415

I have added the sending of "add", "update", "delete", "start", "stop", and "exception" events via telemetry. I have also injected assertions into the existing job_broardcast_tests and executor_test files to verify functionality of the telemetry events.

Testing strategy:

  1. Each test registers to a common TelemetryTestHandler in the test class.
  2. The test performs a job event and the source code calls telemetry execute.
  3. TelemetryTestHandler receives those events and uses send/2 to pass a message back to the test thread
  4. we use "assert_receive" or "refute_receive" to verify the message was received as expected

@coveralls
Copy link

coveralls commented Sep 1, 2020

Pull Request Test Coverage Report for Build 5a0b9f2c1917ba71c5967bfe6be674472d71c4cb-PR-453

  • 31 of 31 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.07%) to 87.2%

Totals Coverage Status
Change from base Build 546758291c94f6a41042a507c35ac1ac5b89eb46: 1.07%
Covered Lines: 327
Relevant Lines: 375

💛 - Coveralls

@mrmarcsmith mrmarcsmith marked this pull request as ready for review September 2, 2020 23:32
@mrmarcsmith mrmarcsmith changed the title WIP: Add telemetry to track metrics Solution: Add telemetry to track metrics Sep 2, 2020
@mrmarcsmith
Copy link
Contributor Author

@maennchen when you get back from vacation I would love your feedback on this!

@rraub
Copy link

rraub commented Sep 3, 2020

@mrmarcsmith It would probably be worth adding some documentation around how a user would consume these telemetry events in the readme or the other markdown doc folder.

@mrmarcsmith
Copy link
Contributor Author

@rraub good idea! I’ll work on that

Copy link
Member

@maennchen maennchen left a comment

Choose a reason for hiding this comment

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

@mrmarcsmith Thanks a lot for the PR!

There's a few cases I think we should handle:

  • JobBroadcaster / init should call [ :quantum, :job, :add ] for all jobs
  • JobBroadcaster / delete_all should call [ :quantum, :job, :delete ] for all jobs
  • [:quantum, :job, *] should contain the job itself in the metadata
  • [:quantum, :job, *] should contain the scheduler module name itself in the metadata (if someone has multiple schedulers)

@maennchen maennchen linked an issue Sep 8, 2020 that may be closed by this pull request
This was referenced Sep 8, 2020
@mrmarcsmith
Copy link
Contributor Author

@maennchen I have completed your requested changes. I am wondering if passing module: __MODULE__ in the metadata was what you were asking for in point 4 because that was already present

@maennchen
Copy link
Member

@mrmarcsmith This is not exactly what I meant with the module:

There's a name for the main scheduler. This would for example be Acme.Scheduler (The module that contains the use Quantum code)

JobBroadcaster: This module name is available as scheduler in the State.

Executor: The scheduler is not yet passed to the executor module. It has to be passed from the Supervisor to ExecutorSupervisor.start_link/1 to ExecutorSupervisor.init/1 to Executor.execute/3.

@maennchen
Copy link
Member

@mrmarcsmith PS: Sorry for the merge conflict. Can you solve it our should I resolve it before merge?

@mrmarcsmith
Copy link
Contributor Author

@maennchen Sounds good! I can take of those merge conflicts

@mrmarcsmith
Copy link
Contributor Author

@maennchen This is ready to be re-reviewed. I ended up adding the scheduler option to the following opts modules so i could pass the scheduler around. Can you think of any end user rational for accessing these ops modules directly that might be a breaking change?

  • Quantum.ExecutorSupervisor.StartOpts
  • Quantum.ExecutorSupervisor.InitOpts
  • Quantum.Executor.StartOpts

Copy link
Member

@maennchen maennchen left a comment

Choose a reason for hiding this comment

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

messages =
for {name, %Job{state: :active} = job} <- jobs do
# Send event to telemetry incase the end user wants to monitor events
:telemetry.execute([:quantum, :job, :delete], %{}, %{
Copy link
Member

Choose a reason for hiding this comment

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

This will only be executed for active jobs. I think we also want to call it on inactive ones.

@maennchen
Copy link
Member

maennchen commented Sep 11, 2020

@mrmarcsmith This is for sure not a breaking change. The modules are not documented and therefore considered internal.

@mrmarcsmith
Copy link
Contributor Author

@maennchen dialyzer is throwing Unknown type: Module.t/0 on the change you made. How do you want to proceed?

@maennchen
Copy link
Member

@mrmarcsmith Oops, that's not the first time i make this error. Should just be atom().

@mrmarcsmith
Copy link
Contributor Author

testing now

@maennchen
Copy link
Member

@mrmarcsmith After this change it's ready to merge 😊

@mrmarcsmith
Copy link
Contributor Author

local test and dialyzer passed! Thank you for the help

@maennchen maennchen merged commit e922d4a into quantum-elixir:master Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Telemetry Metrics
4 participants