Skip to content

Commit

Permalink
Improve Elixir docs in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
José Valim authored Jun 15, 2022
1 parent 976d5b4 commit 68c2c02
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,24 @@ dispatch_session_count() ->

### Elixir

First define the poller with the custom measurements. The first measurement is the built-in `process_info` measurement and the second one is given by a custom module-function-args defined by you:
You typically start the poller as a child in your supervision tree:

```elixir
children = [
{:telemetry_poller,
# include custom measurement as an MFA tuple
measurements: [
{:process_info, name: :my_app_worker, event: [:my_app, :worker], keys: [:memory, :message_queue_len]},
{ExampleApp.Measurements, :dispatch_session_count, []},
],
period: :timer.seconds(10), # configure sampling period - default is :timer.seconds(5)
name: :my_app_poller}
]

Supervisor.start_link(children, strategy: :one_for_one)
```

The poller above has two periodic measurements. The first is the built-in `process_info` measurement that will gather the memory and message queue length of a process. The second is given by a custom module-function-args defined by you, such as below:

```elixir
defmodule ExampleApp.Measurements do
Expand All @@ -56,18 +73,6 @@ defmodule ExampleApp.Measurements do
end
```

```elixir
:telemetry_poller.start_link(
# include custom measurement as an MFA tuple
measurements: [
{:process_info, name: :my_app_worker, event: [:my_app, :worker], keys: [:message, :message_queue_len]},
{ExampleApp.Measurements, :dispatch_session_count, []},
],
period: :timer.seconds(10), # configure sampling period - default is :timer.seconds(5)
name: :my_app_poller
)
```

## Documentation

See [documentation](https://hexdocs.pm/telemetry_poller/) for more concrete examples and usage
Expand Down

0 comments on commit 68c2c02

Please sign in to comment.