Navigation Menu

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

telemetry implementation for Ecto 3 #68

Merged
merged 3 commits into from Nov 15, 2018
Merged

telemetry implementation for Ecto 3 #68

merged 3 commits into from Nov 15, 2018

Conversation

mitchellhenke
Copy link
Contributor

Closes #67

mix.exs Outdated
@@ -39,6 +39,7 @@ defmodule ScoutApm.Mixfile do
{:hackney, "~> 1.0"},

{:approximate_histogram, "~>0.1.1"},
{:telemetry, "~> 0.2.0"},
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants