Skip to content

Commit

Permalink
add metrics collector for BEAM VM
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadRunnr committed Apr 3, 2024
1 parent 3f13bc8 commit 09a76c7
Show file tree
Hide file tree
Showing 6 changed files with 565 additions and 0 deletions.
20 changes: 20 additions & 0 deletions instrumentation/opentelemetry_beam/.gitignore
@@ -0,0 +1,20 @@
.rebar3
_build
_checkouts
_vendor
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
.idea
*.iml
rebar3.crashdump
*~
21 changes: 21 additions & 0 deletions instrumentation/opentelemetry_beam/README.md
@@ -0,0 +1,21 @@
# opentelemetry_beam

Metrics collector to export statistics from the BEAM VM.

The metrics and their names are heavily borrowed from [prometheus.erl](https://github.com/deadtrickster/prometheus.erl).

After installing, setup the desired metrics in your application behaviour before your
top-level supervisor starts. Make sure the API and SDK applications are started before
your application.

```erlang
opentelemetry_beam_metrics:setup(),
...
```

Metrics that are based on microstate accounting need to be enabled explicitly with the `msacc` setting in the `opt_in` option:

```erlang
opentelemetry_beam_metrics:setup(#{opt_in => #{msacc => true}}),
...
```
30 changes: 30 additions & 0 deletions instrumentation/opentelemetry_beam/priv/dev.config
@@ -0,0 +1,30 @@
%%-*-Erlang-*-
[{kernel,
[{logger_level, debug},
{logger,
[{handler, default, logger_std_h,
#{level => debug,
formatter =>
{logger_formatter,
#{single_line => true,
legacy_header => false,
template => [time," ",pid," ",level,": ",msg,"\n"]
}},
config =>
#{sync_mode_qlen => 10000,
drop_mode_qlen => 10000,
flush_qlen => 10000}
}
}
]}
]},

{opentelemetry_experimental,
[{readers,
[
#{module => otel_metric_reader_periodic,
config => #{export_interval_ms => 1000,
exporter => {otel_metric_exporter_console, undefined}}}
]}
]}
].
15 changes: 15 additions & 0 deletions instrumentation/opentelemetry_beam/rebar.config
@@ -0,0 +1,15 @@
%%-*-Erlang-*-
{erl_opts, [debug_info]}.
{deps, [
{opentelemetry_api, "~> 1.3.0"},
{opentelemetry_api_experimental, "~> 0.5.1"}
]}.

{plugins, [rebar3_fmt]}.

{xref_checks, [undefined_function_calls, undefined_functions,
deprecated_function_calls, deprecated_functions]}.
{xref_ignores, []}.

%% development setting
{shell, [{config, "priv/dev.config"}]}.
15 changes: 15 additions & 0 deletions instrumentation/opentelemetry_beam/src/opentelemetry_beam.app.src
@@ -0,0 +1,15 @@
{application, opentelemetry_beam,
[{description, "OpenTelemetry BEAM VM Instrumentation"},
{vsn, "0.1.0"},
{registered, []},
{applications,
[kernel,
stdlib,
opentelemetry_api,
opentelemetry_api_experimental
]},
{env,[]},
{modules, []},
{licenses, ["Apache-2.0"]},
{links, []}
]}.

0 comments on commit 09a76c7

Please sign in to comment.