Skip to content

Commit

Permalink
fix: end all the opened things
Browse files Browse the repository at this point in the history
Indent appropriately.

Lift some doc content to the BaggageSpanProcessor class and focus the
method docs on the method behavior.
  • Loading branch information
robbkidd committed Apr 19, 2024
1 parent e0f5bf4 commit 96a7d62
Showing 1 changed file with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
module OpenTelemetry
module Processor
module Baggage
class BaggageSpanProcessor
# Called when a {Span} is started, if the {Span#recording?} returns true.
#
# The BaggageSpanProcessor reads key/values stored in Baggage in the
# starting span's parent context and adds them as attributes to the span.
#
Expand All @@ -29,7 +26,7 @@ class BaggageSpanProcessor
# @example
# OpenTelemetry::SDK.configure do |c|
# # Add the BaggageSpanProcessor to the collection of span processors
# c.add_span_processor(OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new)
# c.add_span_processor(Honeycomb::OpenTelemetry::Trace::BaggageSpanProcessor.new)
#
# # Because the span processor list is no longer empty, the SDK will not use the
# # values in OTEL_TRACES_EXPORTER to instantiate exporters.
Expand All @@ -43,36 +40,40 @@ class BaggageSpanProcessor
# )
# )
# end
#
# @param [Span] span the {Span} that just started, expected to conform
# to the concrete {Span} interface from the SDK and respond to :add_attributes.
# @param [Context] parent_context the parent {Context} of the newly
# started span.
def on_start(span, parent_context)
class BaggageSpanProcessor
# Called when a {Span} is started, adds Baggage keys/values to the span as attributes.
#
# @param [Span] span the {Span} that just started, expected to conform
# to the concrete {Span} interface from the SDK and respond to :add_attributes.
# @param [Context] parent_context the parent {Context} of the newly
# started span.
def on_start(span, parent_context)
return unless span.respond_to?(:add_attributes) && parent_context.is_a?(::OpenTelemetry::Context)

span.add_attributes(::OpenTelemetry::Baggage.values(context: parent_context))
end
end

# NO-OP method to satisfy the SpanProcessor duck type.
#
# @param [Span] span the {Span} that just ended.
def on_finish(span); end
# NO-OP method to satisfy the SpanProcessor duck type.
#
# @param [Span] span the {Span} that just ended.
def on_finish(span); end

# Export all ended spans to the configured `Exporter` that have not yet
# been exported.
#
# @param [optional Numeric] timeout An optional timeout in seconds.
# @return [Integer] 0 for success and there is nothing to flush so always successful.
def force_flush(timeout: nil)
# Export all ended spans to the configured `Exporter` that have not yet
# been exported.
#
# @param [optional Numeric] timeout An optional timeout in seconds.
# @return [Integer] 0 for success and there is nothing to flush so always successful.
def force_flush(timeout: nil)
0
end
end

# Called when {TracerProvider#shutdown} is called.
#
# @param [optional Numeric] timeout An optional timeout in seconds.
# @return [Integer] 0 for success and there is nothing to stop so always successful.
def shutdown(timeout: nil)
# Called when {TracerProvider#shutdown} is called.
#
# @param [optional Numeric] timeout An optional timeout in seconds.
# @return [Integer] 0 for success and there is nothing to stop so always successful.
def shutdown(timeout: nil)
0
end
end
end
end
Expand Down

0 comments on commit 96a7d62

Please sign in to comment.