Skip to content
Permalink
Browse files
Remove deprecated parent_span_id field
  • Loading branch information
sile committed Oct 30, 2017
1 parent 67e2527 commit 4893a87dbc938a90d35c99a602695e75f2bb5e06
Showing 2 changed files with 16 additions and 18 deletions.
@@ -26,7 +26,6 @@
%%------------------------------------------------------------------------------
-export([get_trace_id/1]).
-export([get_span_id/1]).
-export([get_parent_span_id/1]).
-export([get_debug_id/1]).
-export([get_flags/1]).

@@ -47,7 +46,6 @@
{
trace_id = 0 :: trace_id(),
span_id = 0 :: span_id(),
parent_span_id = 0 :: span_id(),
is_sampled = false :: boolean(),
debug_id :: binary() | undefined
}).
@@ -88,10 +86,6 @@ get_trace_id(Context) ->
get_span_id(Context) ->
(passage_span_context:get_state(Context))#?STATE.span_id.

-spec get_parent_span_id(passage_span_context:context()) -> span_id().
get_parent_span_id(Context) ->
(passage_span_context:get_state(Context))#?STATE.parent_span_id.

%% @private
-spec get_debug_id(passage_span_context:context()) -> {ok, binary()} | eror.
get_debug_id(Context) ->
@@ -118,12 +112,11 @@ make_span_context_state([]) ->
is_sampled = true
};
make_span_context_state([{_, Ref} | _]) ->
#?STATE{trace_id = TraceId, span_id = ParentId} =
#?STATE{trace_id = TraceId} =
passage_span_context:get_state(passage_span:get_context(Ref)),
#?STATE{
trace_id = TraceId,
span_id = rand:uniform(16#FFFFFFFFFFFFFFFF),
parent_span_id = ParentId,
is_sampled = true
}.

@@ -234,35 +227,33 @@ get_flags_from_state(State) ->

-spec state_to_string(#?STATE{}) -> binary().
state_to_string(State) ->
#?STATE{trace_id = TraceId, span_id = SpanId, parent_span_id = ParentId} = State,
#?STATE{trace_id = TraceId, span_id = SpanId} = State,
Flags = get_flags_from_state(State),
list_to_binary(io_lib:format("~.16b:~.16b:~.16b:~.16b",
[TraceId, SpanId, ParentId, Flags])).
[TraceId, SpanId, 0, Flags])).

-spec state_from_string(binary()) -> #?STATE{}.
state_from_string(Str) ->
{ok, [TraceId, SpanId, ParentSpanId, Flags], _} =
{ok, [TraceId, SpanId, _ParentSpanId, Flags], _} =
io_lib:fread("~16u:~16u:~16u:~16u", binary_to_list(Str)),
#?STATE{
trace_id = TraceId,
span_id = SpanId,
parent_span_id = ParentSpanId,
is_sampled = (Flags band ?FLAG_SAMPLED) =/= 0
}.

-spec encode_state(#?STATE{}) -> binary().
encode_state(State) ->
#?STATE{trace_id = TraceId, span_id = SpanId, parent_span_id = ParentId} = State,
#?STATE{trace_id = TraceId, span_id = SpanId} = State,
Flags = get_flags_from_state(State),
<<TraceId:128, SpanId:64, ParentId:64, Flags:32>>.
<<TraceId:128, SpanId:64, 0:64, Flags:32>>.

-spec decode_state(binary()) -> {#?STATE{}, binary()}.
decode_state(<<TraceId:128, SpanId:64, ParentId:64, Flags:32, Bin/binary>>) ->
decode_state(<<TraceId:128, SpanId:64, _ParentId:64, Flags:32, Bin/binary>>) ->
State =
#?STATE{
trace_id = TraceId,
span_id = SpanId,
parent_span_id = ParentId,
is_sampled = (Flags band ?FLAG_SAMPLED) =/= 0
},
{State, Bin}.
@@ -106,7 +106,14 @@ make_spans(Spans) ->
make_span(Span) ->
Context = passage_span:get_context(Span),
TraceId = jaeger_passage_span_context:get_trace_id(Context),
ParentSpanId = jaeger_passage_span_context:get_parent_span_id(Context),
Refs = passage_span:get_refs(Span),
ParentSpanId =
case Refs of
[{_, Parent} | _] ->
jaeger_passage_span_context:get_span_id(
passage_span:get_context(Parent));
_ -> 0
end,
Tags0 = passage_span:get_tags(Span),
Tags1 =
case jaeger_passage_span_context:get_debug_id(Context) of
@@ -120,7 +127,7 @@ make_span(Span) ->
3 => {i64, jaeger_passage_span_context:get_span_id(Context)},
4 => {i64, ParentSpanId},
5 => atom_to_binary(passage_span:get_operation_name(Span), utf8),
6 => make_references(passage_span:get_refs(Span)),
6 => make_references(Refs),
7 => {i32, jaeger_passage_span_context:get_flags(Context)},
8 => {i64, timestamp_to_us(passage_span:get_start_time(Span))},
9 => {i64, get_duration_us(Span)},

0 comments on commit 4893a87

Please sign in to comment.