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

Commit 9e67e1f

Browse files
committed
change oc_stat_stdout_handler to gen_event implementation
1 parent 315dfb9 commit 9e67e1f

File tree

7 files changed

+24
-57
lines changed

7 files changed

+24
-57
lines changed

src/oc_stat_config.erl

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/oc_stat_exporter_stdout.erl

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/oc_stat_stdout_handler.erl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-module(oc_stat_stdout_handler).
2+
3+
-behaviour(gen_event).
4+
5+
-export([init/1,
6+
handle_call/2,
7+
handle_event/2]).
8+
9+
init(Opts) -> {ok, Opts}.
10+
11+
handle_call(_Msg, State) -> {ok, ok, State}.
12+
13+
handle_event({stats, ViewData}, State) ->
14+
[io:format("~s: ~p~n", [Name, Data]) || #{name := Name,
15+
data := Data} <- ViewData],
16+
{ok, State}.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
%% limitations under the License.
1414
%%%------------------------------------------------------------------------
1515

16-
-module(oc_reporter_stdout).
16+
-module(oc_trace_stdout_handler).
1717

1818
-behaviour(gen_event).
1919

test/oc_tab_reporter.erl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323
handle_call/2,
2424
handle_event/2]).
2525

26-
init(_) ->
27-
{ok, application:get_env(opencensus, tab_reporter, #{})}.
26+
init(Tab) -> {ok, Tab}.
2827

2928
handle_call(_Msg, State) -> {ok, ok, State}.
3029

31-
handle_event({spans, Spans}, Opts) ->
32-
Tid = maps:get(tid, Opts),
33-
ets:insert(Tid, Spans),
30+
handle_event({spans, Spans}, Tab) ->
31+
true = ets:insert(Tab, Spans),
3432

35-
{ok, Opts}.
33+
{ok, Tab}.

test/ocp_SUITE.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ end_per_suite(_Config) ->
2828

2929
init_per_testcase(_, Config) ->
3030
Tab = ets:new(reporter_tab, [public, {keypos, #span.span_id}]),
31-
Reporters = [{oc_tab_reporter, []}],
31+
Reporters = [{oc_tab_reporter, Tab}],
3232
application:set_env(opencensus, trace, [{interval, 1},
3333
{handlers, Reporters}]),
34-
application:set_env(opencensus, tab_reporter, #{tid => Tab}),
3534
{ok, _} = application:ensure_all_started(opencensus),
3635
[{tid, Tab} | Config].
3736

test/opencensus_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ end_per_suite(_Config) ->
2626

2727
init_per_testcase(_, Config) ->
2828
Tab = ets:new(reporter_tab, [public, {keypos, #span.span_id}]),
29+
Reporters = [{oc_tab_reporter, Tab}],
2930
application:set_env(opencensus, trace, [{interval, 1},
30-
{handlers, [{oc_tab_reporter, []}]}]),
31-
application:set_env(opencensus, tab_reporter, #{tid => Tab}),
31+
{handlers, Reporters}]),
3232
application:set_env(opencensus, sampler, {oc_sampler_always, []}),
3333
{ok, _} = application:ensure_all_started(opencensus),
3434
[{tid, Tab} | Config].

0 commit comments

Comments
 (0)