quantum-elixir / quantum-core

:watch: Cron-like job scheduler for Elixir
https://hexdocs.pm/quantum/
Apache License 2.0
2.3k stars 147 forks source link

feat: Registers telemetry events #493

Closed isaacsanders closed 2 years ago

isaacsanders commented 2 years ago

Fixes #492

iex(1)> :telemetry_registry.discover_all(:quantum)
:ok
iex(2)> :telemetry_registry.spannable_events()
[{[:quantum, :job], [:start, :stop, :exception]}]
iex(3)> :telemetry_registry.list_events
[
  {[:quantum, :job, :add], Quantum.JobBroadcaster,
   %{
     description: "dispatched when a job is added",
     measurements: "%{}",
     metadata: "%{job: Quantum.Job.t(), scheduler: atom()}"
   }},
  {[:quantum, :job, :delete], Quantum.JobBroadcaster,
   %{
     description: "dispatched when a job is deleted",
     measurements: "%{}",
     metadata: "%{job: Quantum.Job.t(), scheduler: atom()}"
   }},
  {[:quantum, :job, :exception], Quantum.Executor,
   %{
     description: "dispatched on job execution fail",
     measurements: "%{duration: integer()}",
     metadata: "%{telemetry_span_context: term(), job: Quantum.Job.t(), node: Node.t(), scheduler: atom(), kind: :throw | :error | :exit, reason: term(), stacktrace: list()}"
   }},
  {[:quantum, :job, :start], Quantum.Executor,
   %{
     description: "dispatched on job execution start",
     measurements: "%{system_time: integer()}",
     metadata: "%{telemetry_span_context: term(), job: Quantum.Job.t(), node: Node.t(), scheduler: atom()}"
   }},
  {[:quantum, :job, :stop], Quantum.Executor,
   %{
     description: "dispatched on job execution end",
     measurements: "%{duration: integer()}",
     metadata: "%{telemetry_span_context: term(), job: Quantum.Job.t(), node: Node.t(), scheduler: atom(), result: term()}"
   }},
  {[:quantum, :job, :update], Quantum.JobBroadcaster,
   %{
     description: "dispatched when a job is updated",
     measurements: "%{}",
     metadata: "%{job: Quantum.Job.t(), scheduler: atom()}"
   }}
]
coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 9215c94f941991cc7dec5bc56142d8693a46635b-PR-493


Totals Coverage Status
Change from base Build 1387b539ca66ec1b4fd2da6f3bb22554e88b590f: 0.0%
Covered Lines: 362
Relevant Lines: 420

šŸ’› - Coveralls
maennchen commented 2 years ago

@isaacsanders Thanks!

I was wondering, if it would be better to move the events into a module that has a @moduledoc and include telemetry_docs() in there. What do you think?

Should we add something similar to your example above to the tests?

isaacsanders commented 2 years ago

how do you like this newest set of changes?

maennchen commented 2 years ago

@isaacsanders Do you think that we should have a separate module for the Telemetry Docs? I think it would also be fine to add it directly to the Quantum module itself. What do you think?

maennchen commented 2 years ago

@isaacsanders Awesome, thank you šŸ™‚