diff --git a/.env.example b/.env.example index 85aae1690..1fcd2f1c8 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,8 @@ export GITHUB_APP_PEM= export INTERCOM_IDENTITY_SECRET_KEY= export POSTMARK_API_KEY= export S3_BUCKET= +export SCOUT_APP_KEY= +export SCOUT_APP_NAME= export SEGMENT_WRITE_KEY= export SENTRY_DSN= export STRIPE_SECRET_KEY= diff --git a/config/config.exs b/config/config.exs index eab7d7538..54cb8d103 100644 --- a/config/config.exs +++ b/config/config.exs @@ -88,3 +88,9 @@ import_config "#{Mix.env}.exs" # Import Timber, structured logging import_config "timber.exs" + +import_config "scout_apm.exs" + +config :code_corps, CodeCorps.Repo, + loggers: [{Ecto.LogEntry, :log, []}, + {ScoutApm.Instruments.EctoLogger, :log, []}] diff --git a/config/dev.exs b/config/dev.exs index 0c72407e7..977c3e0a9 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -7,7 +7,7 @@ use Mix.Config # watchers to your application. For example, we use it # with brunch.io to recompile .js and .css sources. config :code_corps, CodeCorpsWeb.Endpoint, - http: [port: 4000], + http: [port: 4000, ip: {0, 0, 0, 0, 0, 0, 0, 0}], debug_errors: true, code_reloader: true, check_origin: false diff --git a/config/scout_apm.exs b/config/scout_apm.exs new file mode 100644 index 000000000..9f8f5753d --- /dev/null +++ b/config/scout_apm.exs @@ -0,0 +1,12 @@ +# This configuration file is used for Scout APM. +# See our help docs at http://help.apm.scoutapp.com for more information. +# config/scout_apm.exs +use Mix.Config + +config :scout_apm, + name: System.get_env("SCOUT_APP_NAME") || "", # The app name that will appear within the Scout UI + key: System.get_env("SCOUT_APP_KEY") || "" + +config :phoenix, :template_engines, + eex: ScoutApm.Instruments.EExEngine, + exs: ScoutApm.Instruments.ExsEngine diff --git a/lib/code_corps_web.ex b/lib/code_corps_web.ex index 4ff841482..9bf3b558f 100644 --- a/lib/code_corps_web.ex +++ b/lib/code_corps_web.ex @@ -31,6 +31,7 @@ defmodule CodeCorpsWeb do def controller do quote do use Phoenix.Controller, log: false, namespace: CodeCorpsWeb + use ScoutApm.Instrumentation import Ecto import Ecto.Query diff --git a/mix.exs b/mix.exs index 4490f6b13..8d47268e3 100644 --- a/mix.exs +++ b/mix.exs @@ -28,7 +28,7 @@ defmodule CodeCorps.Mixfile do def application do [ mod: {CodeCorps, []}, - extra_applications: [:timex, :tzdata] + extra_applications: [:scout_apm, :timex, :tzdata] ] end @@ -72,6 +72,7 @@ defmodule CodeCorps.Mixfile do {:joken, "~> 1.5"}, # JWT encoding {:money, "~> 1.2.1"}, {:poison, "~> 3.0", override: true}, + {:scout_apm, "~> 0.0"}, {:scrivener_ecto, "~> 1.2"}, # DB query pagination {:segment, "~> 0.1"}, # Segment analytics {:sentry, "~> 6.0"}, # Sentry error tracking diff --git a/mix.lock b/mix.lock index d57435382..bfa200b24 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,5 @@ -%{"bamboo": {:hex, :bamboo, "0.8.0", "573889a3efcb906bb9d25a1c4caa4ca22f479235e1b8cc3260d8b88dabeb4b14", [:mix], [{:hackney, "~> 1.6", [hex: :hackney, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, optional: false]}]}, +%{"approximate_histogram": {:hex, :approximate_histogram, "0.1.1", "198eb36681e763ed4baab6ca0682acec4ef642f60ba272f251d3059052f4f378", [], [], "hexpm"}, + "bamboo": {:hex, :bamboo, "0.8.0", "573889a3efcb906bb9d25a1c4caa4ca22f479235e1b8cc3260d8b88dabeb4b14", [:mix], [{:hackney, "~> 1.6", [hex: :hackney, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, optional: false]}]}, "bamboo_postmark": {:hex, :bamboo_postmark, "0.4.1", "2ec8fad4d221944f5169ea4346e6e1aef3578282c352c9f7184306d872aa1c26", [:mix], [{:bamboo, "~> 0.5", [hex: :bamboo, optional: false]}, {:hackney, "~> 1.6", [hex: :hackney, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}, {:poison, ">= 1.5.0", [hex: :poison, optional: false]}]}, "base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [], []}, "benchfella": {:hex, :benchfella, "0.3.5", "b2122c234117b3f91ed7b43b6e915e19e1ab216971154acd0a80ce0e9b8c05f5", [:mix], []}, @@ -52,6 +53,7 @@ "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [], []}, "postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]}, "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], []}, + "scout_apm": {:hex, :scout_apm, "0.3.3", "8679378b624b502d7f6e8a1b023b57f4c7ab717380291e2b40ccdb2923457194", [], [{:approximate_histogram, "~>0.1.1", [hex: :approximate_histogram, repo: "hexpm", optional: false]}, {:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:plug, "~>1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, "scrivener": {:hex, :scrivener, "2.3.0", "16b1d744202d47233798205447b35592d96a209241c566304f84ddef63c718b2", [:mix], []}, "scrivener_ecto": {:hex, :scrivener_ecto, "1.2.3", "3255aee5cabfccedcb350f7e5f9f540fb72b8705a763612399264b11ae34faa9", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, optional: false]}, {:postgrex, "~> 0.11.0 or ~> 0.12.0 or ~> 0.13.0", [hex: :postgrex, optional: true]}, {:scrivener, "~> 2.3", [hex: :scrivener, optional: false]}]}, "segment": {:hex, :segment, "0.1.1", "47bf9191590e7a533c105d1e21518e0d6da47c91e8d98ebb649c624db5dfc359", [:mix], [{:httpoison, "~> 0.8", [hex: :httpoison, optional: false]}, {:poison, "~> 1.3 or ~> 2.0", [hex: :poison, optional: false]}]},