Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Various version-related updates (#19)
Browse files Browse the repository at this point in the history
* Update worker_pool deps

* update worker_pool in rebar.config

* use a function to set the version number in the mixfile

* add a little Hex badge

* some documentation-related work in progress

* remove some doc work that's too soon

* don't explicitly mention a version number

* fixup

* fixup: fallback to unsorted tags

* Elixir to 1.3

* allow mix to install rebar3
  • Loading branch information
waisbrot authored Aug 23, 2016
1 parent 76e4592 commit 7cc31d9
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
- REBAR_VSN=3
matrix:
include:
- env: ELIXIR_VSN=1.2.0 REBAR_VSN=
- env: ELIXIR_VSN=1.3.2 REBAR_VSN=
otp_release: 18.2
elixir: $ELIXIR_VSN
before_install:
Expand Down
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
[![Build Status](https://travis-ci.org/WhoopInc/dogstatsde.svg?branch=master)](https://travis-ci.org/WhoopInc/dogstatsde)
[![Hex.pm](https://img.shields.io/hexpm/v/dogstatsde.svg?maxAge=2592000)](https://hex.pm/packages/dogstatsde)

# A dogstatsd client for Erlang #
# A dogstatsd client for Erlang

DogStatsD is Datadog's extension of StatsD. It adds tags to the metrics.

## Configure ##
## Configure

The defaults assume that you're running a statsd server on localhost (true if the agent is installed locally).

There are a number of configuration settings. You can either provide them as environment variables in ALL_CAPS
or in an Erlang config file in all_lowercase.

| name | type | default | info |
| ---- | ---- | ------- | ---- |
| AGENT_ADDRESS | string | `"localhost"` | Hostname or IP where we can send the StatsD UDP packets |
| AGENT_PORT | integer | `8125` | Port that the StatsD agent is listening on |
| GLOBAL_PREFIX | string | `""` | Prefix to attach before all metric names. The `.` will be inserted for you |
| GLOBAL_TAGS | map | `#{}` | Tags to attach to all metrics |
| SEND_METRICS | boolean | `true` | Set to `false` when you're running tests to disable sending any metrics |
| VM_STATS | boolean | `true` | Collect stats on the Erlang VM? |
| VM_STATS_DELAY | integer | `60000` | Time in ms between collection Erlang VM stats |
| VM_STATS_SCHEDULER | boolean | `true` | Collect stats on the scheduler? |
| VM_STATS_BASE_KEY | string | `"erlang.vm"` | All the VM stats will begin with this prefix (after the GLOBAL_PREFIX if that is set) |
| name | type | default | info |
| ------------------ | ------- | ------------- | ------------------------------------------------------------------------------------- |
| AGENT_ADDRESS | string | `"localhost"` | Hostname or IP where we can send the StatsD UDP packets |
| AGENT_PORT | integer | `8125` | Port that the StatsD agent is listening on |
| GLOBAL_PREFIX | string | `""` | Prefix to attach before all metric names. The `.` will be inserted for you |
| GLOBAL_TAGS | map | `#{}` | Tags to attach to all metrics |
| SEND_METRICS | boolean | `true` | Set to `false` when you're running tests to disable sending any metrics |
| VM_STATS | boolean | `true` | Collect stats on the Erlang VM? |
| VM_STATS_DELAY | integer | `60000` | Time in ms between collection Erlang VM stats |
| VM_STATS_SCHEDULER | boolean | `true` | Collect stats on the scheduler? |
| VM_STATS_BASE_KEY | string | `"erlang.vm"` | All the VM stats will begin with this prefix (after the GLOBAL_PREFIX if that is set) |

## Use ##
## Use

### Erlang ###
### Erlang

1. List dogstatsd in your `rebar.config` file

```erlang
{dogstatsd, "1.0.0", {pkg, dogstatsde}}
{dogstatsd, "<version>", {pkg, dogstatsde}}
```

2. List the dogstatsd application in your *.app.src file
Expand All @@ -45,12 +46,12 @@ or in an Erlang config file in all_lowercase.
dogstatsd:gauge("users.active", UserCount, #{ shard => ShardId, version => Vsn })
```

### Elixir ###
### Elixir

1. List dogstatsd dependency in your `mix.exs` file

```elixir
{:dogstatsd, "~> 1.0.0", hex: :dogstatsde}
{:dogstatsd, "~> <version>", hex: :dogstatsde}
```

2. List `:dogstatsd` as an application in your `mix.exs`
Expand All @@ -65,7 +66,7 @@ dogstatsd:gauge("users.active", UserCount, #{ shard => ShardId, version => Vsn }
Dogstatsd.gauge("users.active", user_count, %{ :shard => shard_id, :version => vsn })
```

### VM Stats ###
### VM Stats

If `VM_STATS` is not disabled, dogstatsd will periodically run `erlang:statistics/1` and friends and collect data on the VM's performance:

Expand All @@ -92,7 +93,7 @@ If `VM_STATS` is not disabled, dogstatsd will periodically run `erlang:statistic

![screen-shot of VM stats in Datadog](img/erlang-vm-stats.jpg)

## Metric types ##
## Metric types

All metrics share the same signature:

Expand Down
48 changes: 32 additions & 16 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,54 @@ defmodule Dogstatsd do

def project do
[app: :dogstatsd,
version: "0.5.1",
elixir: "~> 1.2",
version: version(),
name: "Dogstatsd",
elixir: "~> 1.3",
source_url: "https://github.com/WhoopInc/dogstatsde",
docs: [
extras: ["README.md"],
main: "README.md",
],
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end

# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[
applications: [:logger, :worker_pool, :stillir],
mod: {:dogstatsd_app, []}
]
end

# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[
{:stillir, "~> 1.0.0"},
{:worker_pool, "~> 1.0.4"},
{:meck, "~> 0.8.4"} # , only: :test}
{:worker_pool, "~> 2.1.0"},
{:meck, "~> 0.8.4", only: :test}
]
end

def version do
# Fetch or fabricate a version number
{:ok, [{:application, :dogstatsd, appdata}]} = :file.consult("src/dogstatsd.app.src")
case appdata[:vsn] do
:git ->
# Fabricate a magic git version
last_vsn = case System.cmd("git", ["tag", "--sort=version:refname"]) do
{git_tags, 0} ->
git_tags |> String.trim |> String.split |> List.last
{_, 129} ->
{git_tags, 0} = System.cmd("git", ["tag"])
git_tags |> String.trim |> String.split |> List.last
end
{git_hash,0} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
short_hash = git_hash |> String.trim
"#{last_vsn}+build-#{short_hash}"
real_vsn ->
# We get here when this is a downloaded Hex package
real_vsn
end
end
end
end
6 changes: 3 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
%%% -*- mode: erlang; -*-
{erl_opts, [debug_info]}.
{deps, [
{worker_pool, "1.0.4"}
{worker_pool, "2.1.0"}
,{stillir, "1.0.0"}
]}.

{profiles,
[
{dev, [
{erl_opts, [{parse_transform, lager_transform}]}
,{deps, [{lager, "2.1.1"}]}
,{deps, [{lager, "3.2.1"}]}
,{shell, [
{config, "sys.conf"}
,{apps, [dogstatsd]}
]}
]}
,{test, [
{deps, [
{lager, "2.1.1"}
{lager, "3.2.1"}
,{meck, "0.8.4"}
]}
]}
Expand Down
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[{<<"stillir">>,{pkg,<<"stillir">>,<<"1.0.0">>},0},
{<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"1.0.4">>},0}].
{<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"2.1.0">>},0}].
1 change: 1 addition & 0 deletions scripts/install-deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ elif [ $REBAR_VSN -eq 3 ]; then
elif [ $ELIXIR_VSN ]; then
source $HOME/.kiex/elixirs/elixir-${ELIXIR_VSN}.env
mix local.hex --force
mix local.rebar --force
mix deps.get
else
echo Unknown rebar version requested: $REBAR_VSN
Expand Down

0 comments on commit 7cc31d9

Please sign in to comment.