Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config removing detailed spans #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
47 changes: 25 additions & 22 deletions lib/spandex_ecto/ecto_logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defmodule SpandexEcto.EctoLogger do
tracer = config[:tracer] || raise "tracer is a required option for #{inspect(__MODULE__)}"
service = config[:service] || :ecto
truncate = config[:truncate] || 5000
emit_detailed_spans = Keyword.get(config, :emit_detailed_spans, true)

if tracer.current_trace_id() do
now = :os.system_time(:nano_seconds)
Expand Down Expand Up @@ -58,34 +59,36 @@ defmodule SpandexEcto.EctoLogger do

report_error(tracer, log_entry)

if queue_time != 0 do
tracer.start_span("queue")
tracer.update_span(service: service, start: start, completion_time: start + queue_time)
tracer.finish_span()
end
if emit_detailed_spans do
if queue_time != 0 do
tracer.start_span("queue")
tracer.update_span(service: service, start: start, completion_time: start + queue_time)
tracer.finish_span()
end

if query_time != 0 do
tracer.start_span("run_query")
if query_time != 0 do
tracer.start_span("run_query")

tracer.update_span(
service: service,
start: start + queue_time,
completion_time: start + queue_time + query_time
)
tracer.update_span(
service: service,
start: start + queue_time,
completion_time: start + queue_time + query_time
)

tracer.finish_span()
end
tracer.finish_span()
end

if decoding_time != 0 do
tracer.start_span("decode")
if decoding_time != 0 do
tracer.start_span("decode")

tracer.update_span(
service: service,
start: start + queue_time + query_time,
completion_time: now
)
tracer.update_span(
service: service,
start: start + queue_time + query_time,
completion_time: now
)

tracer.finish_span()
tracer.finish_span()
end
end

tracer.finish_span()
Expand Down