lib/opentelemetry/trace/tracer.rb in opentelemetry-api-1.0.0.rc1 vs lib/opentelemetry/trace/tracer.rb in opentelemetry-api-1.0.0.rc2

- old
+ new

@@ -27,19 +27,18 @@ span = nil span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind) Trace.with_span(span) { |s, c| yield s, c } rescue Exception => e # rubocop:disable Lint/RescueException span&.record_exception(e) - span&.status = Status.new(Status::ERROR, - description: "Unhandled exception of type: #{e.class}") + span&.status = Status.error("Unhandled exception of type: #{e.class}") raise e ensure span&.finish end def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil) - Span.new + Span::INVALID end # Used when a caller wants to manage the activation/deactivation and lifecycle of # the Span and its parent manually. # @@ -47,15 +46,15 @@ # # @param [optional Context] with_parent Explicitly managed parent context # # @return [Span] def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) - span_context = OpenTelemetry::Trace.current_span(with_parent).context + span = OpenTelemetry::Trace.current_span(with_parent) - if span_context.valid? - Span.new(span_context: span_context) + if span.context.valid? + span else - Span.new + Span::INVALID end end end end end