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

Misc doc changes #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# The directory Mix will write compiled artifacts to.
/_build
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover
/cover/

# The directory Mix downloads your dependencies sources to.
/deps
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc
# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
prometheus-phoenix-*.tar

# Temporary files for e.g. tests
/tmp

# Emacs
.#*
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Prometheus.io Phoenix Instrumenter
[![Hex.pm](https://img.shields.io/hexpm/v/prometheus_phoenix.svg?maxAge=2592000)](https://hex.pm/packages/prometheus_phoenix)
[![Hex.pm](https://img.shields.io/hexpm/dt/prometheus_phoenix.svg?maxAge=2592000)](https://hex.pm/packages/prometheus_phoenix)

[![Build Status](https://travis-ci.org/deadtrickster/prometheus-phoenix.svg?branch=master)](https://travis-ci.org/deadtrickster/prometheus-phoenix)
[![Documentation](https://img.shields.io/badge/documentation-on%20hexdocs-green.svg)](https://hexdocs.pm/prometheus_phoenix/)
[![Module version](https://img.shields.io/hexpm/v/prometheus_phoenix.svg?maxAge=2592000?style=plastic)](https://hex.pm/packages/prometheus_phoenix)
[![Documentation](https://img.shields.io/badge/hex-docs-green.svg)](https://hexdocs.pm/prometheus_phoenix/)
[![Total Download](https://img.shields.io/hexpm/dt/prometheus_phoenix.svg?maxAge=2592000)](https://hex.pm/packages/prometheus_phoenix)
[![License](https://img.shields.io/hexpm/l/prometheus_phoenix.svg?maxAge=259200)](https://github.com/deadtrickster/prometheus-phoenix/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/deadtrickster/prometheus-phoenix.svg)](https://github.com/deadtrickster/prometheus-phoenix/commits/master)

Phoenix integration for [Prometheus.ex](https://github.com/deadtrickster/prometheus.ex).

Expand All @@ -21,7 +24,7 @@ Phoenix integration for [Prometheus.ex](https://github.com/deadtrickster/prometh
- `phoenix_channel_join_duration_<duration_unit>`;
- `phoenix_channel_receive`
- `phoenix_channel_receive_duration_<duration_unit>`.

## Live endpoint

https://slackinex.herokuapp.com/metrics
Expand All @@ -43,15 +46,15 @@ This integration is configured via <InstrumenterName> `:prometheus` app env key.

[Available in Hex](https://hex.pm/packages/prometheus_phoenix/), the package can be installed as:

1. Add `prometheus_phoenix` to your list of dependencies in `mix.exs`:
1. Add `:prometheus_phoenix` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[{:prometheus_phoenix, "~> 1.3.0"}]
end
```

2. Ensure `prometheus_phoenix` is started before your application:
2. Ensure `:prometheus_phoenix` is started before your application:

```elixir
def application do
Expand Down
61 changes: 31 additions & 30 deletions lib/prometheus/phoenix_instrumenter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ defmodule Prometheus.PhoenixInstrumenter do

### Usage

1. Define your instrumenter:
1. Define your instrumenter:

```elixir
defmodule MyApp.Endpoint.Instrumenter do
use Prometheus.PhoenixInstrumenter
end
```
```elixir
defmodule MyApp.Endpoint.Instrumenter do
use Prometheus.PhoenixInstrumenter
end
```

2. Call `MyApp.Endpoint.Instrumenter.setup/0` when application starts (e.g. supervisor setup):
2. Call `MyApp.Endpoint.Instrumenter.setup/0` when application starts (e.g. supervisor setup):

```elixir
MyApp.Endpoint.Instrumenter.setup()
```
```elixir
MyApp.Endpoint.Instrumenter.setup()
```

3. Add `MyApp.Endpoint.Instrumenter` to Phoenix endpoint instrumenters list:
3. Add `MyApp.Endpoint.Instrumenter` to Phoenix endpoint instrumenters list:

```elixir
config :myapp, MyApp.Endpoint,
...
instrumenters: [MyApp.Endpoint.Instrumenter]
...
```elixir
config :myapp, MyApp.Endpoint,
...
instrumenters: [MyApp.Endpoint.Instrumenter]
...

```
```

### Metrics

Expand Down Expand Up @@ -104,24 +104,25 @@ defmodule Prometheus.PhoenixInstrumenter do

### Custom Labels

Custom labels can be defined by implementing label_value/2 function in instrumenter directly or
Custom labels can be defined by implementing `label_value/2` function in instrumenter directly or
by calling exported function from other module.

```elixir
config :prometheus, MyApp.Endpoint.Instrumenter,
controller_call_labels: [:controller,
:my_private_label,
{:label_from_other_module, Module}, # eqv to {Module, label_value}
{:non_default_label_value, {Module, custom_fun}}]
```elixir
config :prometheus, MyApp.Endpoint.Instrumenter,
controller_call_labels: [:controller,
:my_private_label,
{:label_from_other_module, Module}, # eqv to {Module, label_value}
{:non_default_label_value, {Module, custom_fun}}]

defmodule MyApp.Endpoint.Instrumenter do
use Prometheus.PhoenixInstrumenter
defmodule MyApp.Endpoint.Instrumenter do
use Prometheus.PhoenixInstrumenter

def label_value(:my_private_label, conn) do
...
def label_value(:my_private_label, conn) do
...
end
end
end
```
```

"""

import Phoenix.Controller
Expand Down
11 changes: 6 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule PrometheusPhoenix.Mixfile do
use Mix.Project

@source_url "https://github.com/deadtrickster/prometheus-phoenix"
@version "1.3.0"

def project do
Expand All @@ -14,9 +15,10 @@ defmodule PrometheusPhoenix.Mixfile do
description: description(),
package: package(),
docs: [
main: Prometheus.PhoenixInstrumenter,
main: "readme",
source_ref: "v#{@version}",
source_url: "https://github.com/deadtrickster/prometheus-phoenix"
source_url: @source_url,
extras: ["README.md"]
]
]
end
Expand All @@ -36,7 +38,7 @@ defmodule PrometheusPhoenix.Mixfile do
maintainers: ["Ilya Khaprov"],
licenses: ["MIT"],
links: %{
"GitHub" => "https://github.com/deadtrickster/prometheus-phoenix",
"GitHub" => @source_url,
"Prometheus.erl" => "https://hex.pm/packages/prometheus",
"Prometheus.ex" => "https://hex.pm/packages/prometheus_ex",
"Plugs Instrumenter/Exporter" => "https://hex.pm/packages/prometheus_plugs",
Expand All @@ -53,8 +55,7 @@ defmodule PrometheusPhoenix.Mixfile do
{:phoenix, "~> 1.4"},
{:jason, "~> 1.1", only: [:dev, :test]},
{:phoenix_html, "~> 2.10", only: [:test]},
{:ex_doc, "~> 0.16.1", only: [:dev]},
{:earmark, "~> 1.2", only: [:dev]},
{:ex_doc, ">= 0.0.0", only: [:dev]},
{:credo, git: "https://github.com/rrrene/credo", only: [:dev, :test], runtime: false}
]
end
Expand Down
28 changes: 16 additions & 12 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"credo": {:git, "https://github.com/rrrene/credo", "27c6935403de091b0c538ab2ccfcf876727fa65d", []},
"earmark": {:hex, :earmark, "1.3.0", "17f0c38eaafb4800f746b457313af4b2442a8c2405b49c645768680f900be603", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.16.4", "4bf6b82d4f0a643b500366ed7134896e8cccdbab4d1a7a35524951b25b1ec9f0", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
"phoenix": {:hex, :phoenix, "1.4.6", "8535f4a01291f0fbc2c30c78c4ca6a2eacc148db5178ad76e8b2fc976c590115", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"},
"phoenix_html": {:hex, :phoenix_html, "2.13.0", "3bad10de5efb6c590f7aa5b316ad0d3faa054715414c9b562c410de4ffb885c5", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.3.0", "17f0c38eaafb4800f746b457313af4b2442a8c2405b49c645768680f900be603", [:mix], [], "hexpm", "f8b8820099caf0d5e72ae6482d2b0da96f213cbbe2b5b2191a37966e119eaa27"},
"earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm", "6cbe761d6a0ca5a31a0931bf4c63204bceb64538e664a8ecf784a9a6f3b875f1"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"phoenix": {:hex, :phoenix, "1.4.6", "8535f4a01291f0fbc2c30c78c4ca6a2eacc148db5178ad76e8b2fc976c590115", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "17aa6f4909e41eebfa7589b61c71f0ebe8fdea997194fd85596e629bbf8d3e15"},
"phoenix_html": {:hex, :phoenix_html, "2.13.0", "3bad10de5efb6c590f7aa5b316ad0d3faa054715414c9b562c410de4ffb885c5", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "6bce79ae6987822c288f7653d89c971fef276d1a6977757d6f61e4984b88dc5a"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.1", "6668d787e602981f24f17a5fbb69cc98f8ab085114ebfac6cc36e10a90c8e93c", [:mix], [], "hexpm", "a3d890aaa3156d51056179dcaaadaf32b844f71656bb27c58756f2b97875c36c"},
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm", "daa5fee4209c12c3c48b05a96cf88c320b627c9575f987554dcdc1fdcdf2c15e"},
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm", "73c1682f0e414cfb5d9b95c8e8cd6ffcfdae699e3b05e1db744e58b7be857759"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
"prometheus": {:hex, :prometheus, "4.2.0", "06c58bfdfe28d3168b926da614cb9a6d39593deebde648a5480e32dfa3c370e9", [:mix, :rebar3], [], "hexpm"},
"prometheus_ex": {:hex, :prometheus_ex, "3.0.3", "5d722263bb1f7a9b1d02554de42e61ea672b4e3c07c3f74e23ce35ab5e111cfa", [:mix], [{:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm"},
"prometheus": {:hex, :prometheus, "4.2.0", "06c58bfdfe28d3168b926da614cb9a6d39593deebde648a5480e32dfa3c370e9", [:mix, :rebar3], [], "hexpm", "286536224ed4fdaca44d230d0b3c65e862e04971b8564443ef1f54ee07aa4328"},
"prometheus_ex": {:hex, :prometheus_ex, "3.0.3", "5d722263bb1f7a9b1d02554de42e61ea672b4e3c07c3f74e23ce35ab5e111cfa", [:mix], [{:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm", "2327541e0bebbdf8c6d7d7dd20ad2f2958cae0704eed0f038d33018908866f85"},
}