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
telemetry implementation for Ecto 3 #68
Conversation
mix.exs
Outdated
@@ -39,6 +39,7 @@ defmodule ScoutApm.Mixfile do | |||
{:hackney, "~> 1.0"}, | |||
|
|||
{:approximate_histogram, "~>0.1.1"}, | |||
{:telemetry, "~> 0.2.0"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to cause problems installing the agent on older versions of the Phoenix stack? For instance, we had to do the 0.0.0 thing for poison and just guard against functions not being present at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added fd7b299 to handle that
end | ||
|
||
def handle_event([_app, _repo, :query], _value, metadata, _config) do | ||
ScoutApm.Instruments.EctoLogger.record(metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay code reuse.
|> Enum.map(& &1 |> Macro.underscore() |> String.to_atom()) | ||
|> Kernel.++([:query]) | ||
|
||
Telemetry.attach("scout-ecto-query-handler", query_event, ScoutApm.Instruments.EctoTelemetry, :handle_event, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that scout-ecto-query-handler
string mean anything? Can we instrument multiple repos with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scout-ecto-query-handler
does need to be unique. https://hexdocs.pm/telemetry/0.2.0/Telemetry.html#attach_many/5 is available, though we could also make the string ID unique by including the repo information in it which would allow multiple calls to EctoTelemetry.attach
?
106ead9
to
4e0d99c
Compare
Closes #67