Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 4787ad5

Browse files
arkgiltsloughter
authored andcommitted
Update example application (#162)
1 parent 2430bf2 commit 4787ad5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

examples/helloworld/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The OpenCensus Erlang API artifact is available here: https://hexdocs.pm/opencen
1010

1111
#### Prerequisites
1212

13-
[Erlang/OTP 20](https://erlang.org) and [rebar3](https://rebar3.org) are required.
13+
[Erlang/OTP 20](https://erlang.org) and [rebar3](https://rebar3.org) are required.
1414

1515
#### Using
1616

@@ -41,7 +41,7 @@ Add `opencensus` as a dependency in `rebar.config`. For development purposes it
4141
```erlang
4242
[
4343
{opencensus, [{sampler, {oc_sampler_always, []}},
44-
{reporter, {oc_reporter_stdout, []}},
44+
{reporters, [{oc_reporter_stdout, []}]},
4545
{stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]}
4646
].
4747
```
@@ -70,9 +70,12 @@ Add `opencensus` as a dependency in `rebar.config`. For development purposes it
7070

7171
Building the application with `rebar3 compile` will fetch the OpenCensus Erlang library and its dependencies.
7272

73-
When our application starts it needs to create and subscribe to the statistics that we'll record. So a call to `subscribe_views/0` is added to the application start function, `helloworld_app:start/2`:
73+
When our application starts it needs to create and subscribe to the statistics that we'll record. So a call to `create_measures/0` and `subscribe_views/0` is added to the application start function, `helloworld_app:start/2`:
7474
7575
```erlang
76+
create_measures() ->
77+
oc_stat_measure:new('my.org/measure/video_size', "Size of a processed video", bytes).
78+
7679
subscribe_views() ->
7780
oc_stat_view:subscribe(#{name => "video_size",
7881
description => "size of processed videos",

examples/helloworld/config/sys.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{opencensus, [{sampler, {oc_sampler_always, []}},
3-
{reporter, {oc_reporter_stdout, []}},
3+
{reporters, [{oc_reporter_stdout, []}]},
44

55
{stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]},
66

examples/helloworld/src/helloworld_app.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
%%====================================================================
1616

1717
start(_StartType, _StartArgs) ->
18+
create_measures(),
1819
subscribe_views(),
1920
helloworld_sup:start_link().
2021

@@ -26,6 +27,9 @@ stop(_State) ->
2627
%% Internal functions
2728
%%====================================================================
2829

30+
create_measures() ->
31+
oc_stat_measure:new('my.org/measure/video_size', "Size of a processed video", bytes).
32+
2933
subscribe_views() ->
3034
oc_stat_view:subscribe(#{name => "video_size",
3135
description => "size of processed videos",

0 commit comments

Comments
 (0)