prometheus-ecto icon indicating copy to clipboard operation
prometheus-ecto copied to clipboard

Record Idle Time, Add Repo Label & Make config accessible in label_value()

Open ackerdev opened this issue 3 years ago • 4 comments

Adds support for the new idle_time metric introduced in ecto_sql 3.3.0, adds repo labeling, and allows config to be accessed in label_value().

Repo label and the config change would be breaking changes.

For some context on the label_value() config change, my usecase is that we have multiple repos across multiple apps within an umbrella application. We want to be able to record both the repo and app so we can split out results in our dashboards appropriately. This change will allow me to do the following:

:telemetry.attach_many("handler-id", repo_query_event_names, &MyRepoInstrumenter.handle_event/4, %{application: :my_app})

defmodule MyRepoInstrumenter do
  use Prometheus.EctoInstrumenter

  def label_value(:application, _entry, config) do
    config.application
  end
end

I tried to split each change into it's own commit if you want to pick-and-choose which changes to accept or review them individually.

Closes #26

ackerdev avatar Mar 10 '21 21:03 ackerdev

Hi, thank you for this. Please bump version in mix.exs

deadtrickster avatar Mar 11 '21 19:03 deadtrickster

Done, thank you for taking the time to review & merge!

ackerdev avatar Mar 11 '21 20:03 ackerdev

Also, added some docs updates that will also close #24

ackerdev avatar Mar 11 '21 20:03 ackerdev

Hi, this MR looks gorgeous! Any chance it can be merged soon?

NicolasMarlier avatar Sep 20 '21 13:09 NicolasMarlier