Note: This post is a summary of information paraphrased from an excellent blog post by Christian Sepulveda.
Create the app and download the necessary dependencies.
| defmodule MyApp.Telemetry do | |
| require Logger | |
| def handle_event([:my_app, :repo, :query], measurements, metadata, _config) do | |
| milliseconds = System.convert_time_unit(measurements.total_time, :native, :millisecond) | |
| # did the query take longer than 100ms? | |
| if milliseconds > 100 do | |
| # log it as a warning | |
| Logger.warn("SLOW QUERY: ms: #{milliseconds}, query: #{metadata.query}") |
| # Preloading usually required an extra query. | |
| # To do it in one query, a `join` is needed, and the call to `preload` needs to know the name of join | |
| # This macro does both the `join` and `preload` together | |
| defmodule Preloader do | |
| import Ecto, only: [assoc: 2] | |
| alias Ecto.Query.Builder.{Join, Preload} | |
| defmacro preload_join(query, association) do | |
| expr = quote do: assoc(l, unquote(association)) | |
| binding = quote do: [l] |
Create the app and download the necessary dependencies.
See Configuring NGINX to accept the PROXY Protocol - NGINX
upstream wsserver {
server 127.0.0.1:9000;
}| 0815.ru | |
| 0wnd.net | |
| 0wnd.org | |
| 10minutemail.co.za | |
| 10minutemail.com | |
| 123-m.com | |
| 1fsdfdsfsdf.tk | |
| 1pad.de | |
| 20minutemail.com | |
| 21cn.com |
Visit my blog or connect with me on Twitter
git init
or
| defmodule MyApp.Scheduler do | |
| @moduledoc """ | |
| Schedules a Mix task to be run at a given interval in milliseconds. | |
| ## Options | |
| - `:task`: The name of the Mix task to run. | |
| - `:args`: A list of arguments to pass to the Mix task's `run/1` function. | |
| - `:interval`: The time interval in millisconds to rerun the task. |