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

Commit 315dfb9

Browse files
committed
update tests to match new API
1 parent a2b35d5 commit 315dfb9

18 files changed

+84
-46
lines changed

src/oc_internal_timer.erl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
%%%------------------------------------------------------------------------
2+
%% Copyright 2017, OpenCensus Authors
3+
%% Licensed under the Apache License, Version 2.0 (the "License");
4+
%% you may not use this file except in compliance with the License.
5+
%% You may obtain a copy of the License at
6+
%%
7+
%% http://www.apache.org/licenses/LICENSE-2.0
8+
%%
9+
%% Unless required by applicable law or agreed to in writing, software
10+
%% distributed under the License is distributed on an "AS IS" BASIS,
11+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
%% See the License for the specific language governing permissions and
13+
%% limitations under the License.
14+
%%%------------------------------------------------------------------------
15+
116
-module(oc_internal_timer).
217

318
-callback ping() -> ok.

src/oc_reporter_pid.erl

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

26-
init(Pid) -> Pid.
26+
init(Pid) -> {ok, Pid}.
2727

2828
handle_call(_Msg, State) -> {ok, ok, State}.
2929

30-
handle_event(Spans, Pid) ->
30+
handle_event({spans, Spans}, Pid) ->
3131
[Pid ! {span, Span} || Span <- Spans],
3232
{ok, Pid}.

src/oc_reporter_stdout.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
handle_call/2,
2222
handle_event/2]).
2323

24-
init(_) ->
25-
ok.
24+
init(Opts) -> {ok, Opts}.
2625

2726
handle_call(_Msg, State) -> {ok, ok, State}.
2827

src/oc_span.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ finish_span(#span_ctx{tracestate=Tracestate}, Span=#span{}) ->
4747
%% update tracestate to what the context has when finished
4848
Span1 = Span#span{end_time=EndTime,
4949
tracestate=Tracestate},
50-
oc_reporter:store_span(Span1);
50+
oc_trace_reporter:store_span(Span1);
5151
finish_span(_, _) ->
5252
true.
5353

src/oc_stat_sup.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
%% limitations under the License.
1414
%%%------------------------------------------------------------------------
1515

16+
%% @private
17+
1618
-module(oc_stat_sup).
1719

1820
-export([start_link/1, init/1]).

src/oc_trace.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,17 @@ update_trace_options(should_sample, #span_ctx{trace_id=TraceId,
203203
%% Finish a span, setting the end_time.
204204
%% @end
205205
%%--------------------------------------------------------------------
206-
-spec finish_span(maybe(opencensus:span_ctx())) -> boolean().
206+
-spec finish_span(maybe(opencensus:span_ctx())) -> ok | {error, invalid_span} | {error, no_report_buffer}.
207207
finish_span(SpanCtx=#span_ctx{span_id=SpanId,
208208
trace_options=TraceOptions}) when ?IS_ENABLED(TraceOptions) ->
209209
case ets:take(?SPAN_TAB, SpanId) of
210210
[SpanData] ->
211211
oc_span:finish_span(SpanCtx, SpanData);
212212
_ ->
213-
false
213+
{error, invalid_span}
214214
end;
215215
finish_span(_) ->
216-
true.
216+
{error, invalid_span}.
217217

218218
%%--------------------------------------------------------------------
219219
%% @doc

src/oc_trace_reporter.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ start_link(Handlers) ->
4343
Other -> Other
4444
end.
4545

46-
-spec store_span(opencensus:span()) -> true | {error, invalid_span} | {error, no_report_buffer}.
46+
-spec store_span(opencensus:span()) -> ok | {error, invalid_span} | {error, no_report_buffer}.
4747
store_span(Span=#span{}) ->
4848
try
4949
[{_, Buffer}] = ets:lookup(?BUFFER_STATUS, current_buffer),
50-
ets:insert(Buffer, Span)
50+
true = ets:insert(Buffer, Span),
51+
ok
5152
catch
5253
error:badarg ->
5354
{error, no_report_buffer}

src/oc_trace_sup.erl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
%% limitations under the License.
1414
%%%------------------------------------------------------------------------
1515

16+
%% @private
17+
1618
-module(oc_trace_sup).
1719

1820
-behaviour(supervisor).
1921

2022
-export([start_link/1, init/1]).
2123

2224
-include("opencensus.hrl").
25+
-include("oc_logger.hrl").
2326

2427
start_link(Opts) ->
2528
supervisor:start_link(?MODULE, Opts).

src/ocp.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ current_tags() ->
171171
%% Finishes the span in the current pdict context.
172172
%% @end
173173
%%--------------------------------------------------------------------
174-
-spec finish_span() -> boolean().
174+
-spec finish_span() -> ok | {error, invalid_span} | {error, no_report_buffer}.
175175
finish_span() ->
176176
CurrentCtx = current_span_ctx(),
177177
ParentCtx = oc_trace:parent_span_ctx(CurrentCtx),

src/opencensus_sup.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
%% See the License for the specific language governing permissions and
1313
%% limitations under the License.
1414
%%
15+
%%%------------------------------------------------------------------------
16+
1517
%% @doc opencensus top level supervisor.
18+
%% @private
1619
%% @end
17-
%%%------------------------------------------------------------------------
1820

1921
-module(opencensus_sup).
2022

@@ -24,15 +26,13 @@
2426

2527
-export([init/1]).
2628

27-
-define(SERVER, ?MODULE).
28-
2929
start_link() ->
3030
supervisor:start_link(?MODULE, []).
3131

3232
init([]) ->
3333
ok = oc_sampler:init(application:get_env(opencensus, sampler, {oc_sampler_always, []})),
3434

35-
StatOpts = application:get_env(opencensus, metric, []),
35+
StatOpts = application:get_env(opencensus, stat, []),
3636
StatSup = #{id => stat,
3737
start => {oc_stat_sup, start_link, [StatOpts]},
3838
type => supervisor},

0 commit comments

Comments
 (0)