Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 8 additions & 37 deletions src/riak_core_dtrace.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,8 @@ dtrace(ArgList) ->
undefined ->
case application:get_env(riak_core, dtrace_support) of
{ok, true} ->
case string:to_float(erlang:system_info(version)) of
{5.8, _} ->
%% R14B04
put(?MAGIC, dtrace),
if ArgList == enabled_check -> true;
true -> dtrace(ArgList)
end;
{Num, _} when Num > 5.8 ->
%% R15B or higher, though dyntrace option
%% was first available in R15B01.
case dyntrace:available() of
true ->
put(?MAGIC, dyntrace),
if ArgList == enabled_check -> true;
true -> dtrace(ArgList)
Expand All @@ -78,10 +70,6 @@ dtrace(ArgList) ->
if ArgList == enabled_check -> true;
true -> erlang:apply(dyntrace, p, ArgList)
end;
dtrace ->
if ArgList == enabled_check -> true;
true -> erlang:apply(dtrace, p, ArgList)
end;
_ ->
false
end.
Expand Down Expand Up @@ -119,59 +107,42 @@ dtrace(Int0, Int1, Ints, String0, String1, Strings)
dtrace([Int0, Int1] ++ Ints ++ [S0, String1] ++ Strings)
end.

-spec enabled() -> boolean().
enabled() ->
dtrace(enabled_check).

-spec put_tag(iodata() | undefined) -> boolean() | undefined.
put_tag(Tag) ->
case enabled() of
true ->
FTag = iolist_to_binary(Tag),
put(?DTRACE_TAG_KEY, FTag),
dyntrace:put_tag(FTag);
false ->
ok
undefined
end.

timeit0(ArgList) ->
try
erlang:apply(dyntrace, p, ArgList)
catch
error:undef ->
try
erlang:apply(dtrace, p, ArgList)
catch
error:undef ->
false
end
false
end.

timeit_mg(ArgList) ->
case riak_core_mochiglobal:get(?MAGIC) of
undefined ->
case application:get_env(riak_core, dtrace_support) of
{ok, true} ->
case string:to_float(erlang:system_info(version)) of
{5.8, _} ->
%% R14B04
riak_core_mochiglobal:put(?MAGIC, dtrace),
timeit_mg(ArgList);
{Num, _} when Num > 5.8 ->
%% R15B or higher, though dyntrace option
%% was first available in R15B01.
riak_core_mochiglobal:put(?MAGIC, dyntrace),
timeit_mg(ArgList);
_ ->
riak_core_mochiglobal:put(?MAGIC, unsupported),
false
end;
riak_core_mochiglobal:put(?MAGIC, dyntrace),
timeit_mg(ArgList);
_ ->
riak_core_mochiglobal:put(?MAGIC, unsupported),
false
end;
dyntrace ->
erlang:apply(dyntrace, p, ArgList);
dtrace ->
erlang:apply(dtrace, p, ArgList);
unsupported ->
false
end.
Expand Down