From 1b749e02658c8af88fe2faeb059e375f66f619fb Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Fri, 28 Oct 2016 14:31:23 -0400 Subject: [PATCH] only set end_time on finish, not start --- lib/lightstep/tracer/span.rb | 2 -- lib/lightstep/tracer/tracer.rb | 7 +------ spec/lightstep_spec.rb | 8 ++++---- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/lightstep/tracer/span.rb b/lib/lightstep/tracer/span.rb index 5254365..5e9aaac 100644 --- a/lib/lightstep/tracer/span.rb +++ b/lib/lightstep/tracer/span.rb @@ -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 diff --git a/lib/lightstep/tracer/tracer.rb b/lib/lightstep/tracer/tracer.rb index 6b0bb9d..0d9adca 100644 --- a/lib/lightstep/tracer/tracer.rb +++ b/lib/lightstep/tracer/tracer.rb @@ -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 diff --git a/spec/lightstep_spec.rb b/spec/lightstep_spec.rb index e7b50a0..6922493 100644 --- a/spec/lightstep_spec.rb +++ b/spec/lightstep_spec.rb @@ -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