only set end_time on finish, not start

This commit is contained in:
Nick Gauthier 2016-10-28 14:31:23 -04:00
Родитель bf6324aabe
Коммит 1b749e0265
3 изменённых файлов: 5 добавлений и 12 удалений

Просмотреть файл

@ -13,7 +13,6 @@ module LightStep
child_of_guid: nil,
trace_guid:,
start_micros:,
end_micros: nil,
tags: nil
)
@tags = Hash(tags)
@ -23,7 +22,6 @@ module LightStep
@guid = tracer.generate_guid
self.operation_name = operation_name
self.start_micros = start_micros
self.end_micros = end_micros
self.trace_guid = trace_guid
set_tag(:parent_span_guid, child_of_guid) if !child_of_guid.nil?
end

Просмотреть файл

@ -72,13 +72,9 @@ module LightStep
@max_flush_period_micros = [DEFAULT_MAX_REPORTING_PERIOD_SECS, secs].min * 1E6
end
# ----------------------------------------------------------------------------
# OpenTracing API
# ----------------------------------------------------------------------------
# Starts a new span.
# TODO(ngauthier@gmail.com) inherit SpanContext from references
def start_span(operation_name, child_of: nil, start_time: nil, end_time: nil, tags: nil)
def start_span(operation_name, child_of: nil, start_time: nil, tags: nil)
child_of_guid = nil
trace_guid = nil
if Span === child_of
@ -94,7 +90,6 @@ module LightStep
child_of_guid: child_of_guid,
trace_guid: trace_guid,
start_micros: start_time.nil? ? now_micros : micros(start_time),
end_micros: end_time.nil? ? nil : micros(end_time),
tags: tags
)
end

Просмотреть файл

@ -80,12 +80,12 @@ describe LightStep do
span1.finish
expect(span1.start_micros).to eq(t1_micros)
span2 = tracer.start_span('test2', end_time: t1)
span2.finish
span2 = tracer.start_span('test2')
span2.finish(end_time: t1)
expect(span2.end_micros).to eq(t1_micros)
span3 = tracer.start_span('test3', start_time: t1, end_time: t2)
span3.finish
span3 = tracer.start_span('test3', start_time: t1)
span3.finish(end_time: t2)
expect(span3.start_micros).to eq(t1_micros)
expect(span3.end_micros).to eq(t2_micros)
end