Skip to content

Commit

Permalink
Guard clauses for trace and span macros (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregMefford authored and zachdaniel committed Jan 25, 2021
1 parent 46a7183 commit d14f78c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/spandex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Spandex do
strategy = opts[:strategy]

if strategy.trace_active?(opts[:trace_key]) do
Logger.error("Tried to start a trace over top of another trace: #{name}.")
Logger.error("Tried to start a trace over top of another trace. name: #{inspect(name)}")
{:error, :trace_running}
else
do_start_trace(name, opts)
Expand Down Expand Up @@ -351,7 +351,7 @@ defmodule Spandex do
strategy = opts[:strategy]

if strategy.trace_active?(opts[:trace_key]) do
Logger.error("Tried to continue a trace over top of another trace: #{name}.")
Logger.error("Tried to continue a trace over top of another trace. name: #{inspect(name)}")
{:error, :trace_already_present}
else
do_continue_trace(name, span_context, opts)
Expand Down Expand Up @@ -393,7 +393,7 @@ defmodule Spandex do
strategy = opts[:strategy]

if strategy.trace_active?(opts[:trace_key]) do
Logger.error("Tried to continue a trace over top of another trace: #{name}.")
Logger.error("Tried to continue a trace over top of another trace. name: #{inspect(name)}")
{:error, :trace_already_present}
else
do_continue_trace_from_span(name, span, opts)
Expand Down
4 changes: 2 additions & 2 deletions lib/tracer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ defmodule Spandex.Tracer do
end

@impl Spandex.Tracer
defmacro trace(name, opts \\ [], do: body) do
defmacro trace(name, opts \\ [], do: body) when is_binary(name) do
quote do
opts = unquote(opts)

Expand All @@ -140,7 +140,7 @@ defmodule Spandex.Tracer do
end

@impl Spandex.Tracer
defmacro span(name, opts \\ [], do: body) do
defmacro span(name, opts \\ [], do: body) when is_binary(name) do
quote do
opts = unquote(opts)
name = unquote(name)
Expand Down

0 comments on commit d14f78c

Please sign in to comment.