Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sashman/app_optex
Elixir AppOptics client
https://github.com/sashman/app_optex
apm appoptics elixir
Last synced: about 1 month ago
JSON representation
Elixir AppOptics client
- Host: GitHub
- URL: https://github.com/sashman/app_optex
- Owner: sashman
- License: mit
- Created: 2019-04-02T16:08:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-14T07:58:10.000Z (over 5 years ago)
- Last Synced: 2024-08-10T06:51:47.509Z (3 months ago)
- Topics: apm, appoptics, elixir
- Language: Elixir
- Size: 57.6 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-elixir - app_optex - Client for AppOptics API. Send metrics and tags to AppOptics time series service. (Instrumenting / Monitoring)
- awesome-elixir - app_optex - Client for AppOptics API. Send metrics and tags to AppOptics time series service. (Instrumenting / Monitoring)
README
# AppOptex
![CircleCI](https://img.shields.io/circleci/project/github/sashman/app_optex.svg)
![Hex.pm](https://img.shields.io/hexpm/v/app_optex.svg)Client for [AppOptics API](https://docs.appoptics.com/api/), as listed on [AppOptics community created language bindings](https://docs.appoptics.com/kb/custom_metrics/api/#community-created-language-bindings)
## Installation
The [package](https://hex.pm/packages/app_optex) can be installed
by adding `app_optex` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:app_optex, "~> 0.1.0"}
]
end
```Documentation can be found at [https://hexdocs.pm/app_optex](https://hexdocs.pm/app_optex).
## Usage
Uses the `APPOPTICS_TOKEN` environment variable.
### Send a single measurement
```elixir
iex> AppOptex.measurement("my.metric", 10, %{my_tag: "value"})
:ok
iex> AppOptex.measurement(%{name: "my.metric", value: 10}, %{my_tag: "value"})
:ok
```### Send multiple measurements
```elixir
iex> AppOptex.measurements([%{name: "my.metric", value: 1}, %{name: "my.other_metric", value: 5}], %{my_tag: "value"})
:ok
```### Read metrics
```elixir
iex> AppOptex.read_measurements("my.metric", 60, %{duration: 86400})
%{
"attributes" => %{"created_by_ua" => "hackney/1.15.1"},
"links" => [],
"name" => "my.metric",
"resolution" => 60,
"series" => [
%{
"measurements" => [%{"time" => 1554720060, "value" => 10.0}],
"tags" => %{"my_tag" => "value"}
}
]
}
```### Set global tags
These tags will be applied to every sent measurement.
```elixir
iex> AppOptex.put_global_tags(%{my: "tag"})
:ok
```### Read global tags
```elixir
iex> AppOptex.get_global_tags()
%{my: "tag"}
```### Send using a queue
```elixir
iex> AppOptex.push_to_queue([%{name: "my.metric.1", value: 1}], %{test: true})
:ok
iex> AppOptex.push_to_queue([%{name: "my.metric.2", value: 1}], %{test: true})
:ok
iex> AppOptex.push_to_queue([%{name: "my.metric.3", value: 1}], %{test: true})
:ok
iex> AppOptex.flush_queue()
:ok
```