lib/jaeger/client/span.rb in jaeger-client-0.7.1 vs lib/jaeger/client/span.rb in jaeger-client-0.8.0

- old
+ new

@@ -21,38 +21,54 @@ @context = context @operation_name = operation_name @reporter = reporter @start_time = start_time @references = references - @tags = tags.map { |key, value| ThriftTagBuilder.build(key, value) } + @tags = [] @logs = [] + + tags.each { |key, value| set_tag(key, value) } end # Set a tag value on this span # # @param key [String] the key of the tag # @param value [String, Numeric, Boolean] the value of the tag. If it's not # a String, Numeric, or Boolean it will be encoded with to_s def set_tag(key, value) + if key == 'sampling.priority' + if value.to_i > 0 + return self if @context.debug? + + @context.flags = @context.flags | SpanContext::Flags::SAMPLED | SpanContext::Flags::DEBUG + else + @context.flags = @context.flags & ~SpanContext::Flags::SAMPLED + end + return self + end + # Using Thrift::Tag to avoid unnecessary memory allocations @tags << ThriftTagBuilder.build(key, value) + + self end # Set a baggage item on the span # # @param key [String] the key of the baggage item # @param value [String] the value of the baggage item def set_baggage_item(key, value) + @context.set_baggage_item(key, value) self end # Get a baggage item # # @param key [String] the key of the baggage item # # @return Value of the baggage item def get_baggage_item(key) - nil + @context.get_baggage_item(key) end # Add a log entry to this span # # @deprecated Use {#log_kv} instead.