lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-1.3.0 vs lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-1.3.1
- old
+ new
@@ -345,11 +345,17 @@
end
def trim_span_attributes(attrs)
return if attrs.nil?
- excess = attrs.size - @span_limits.attribute_count_limit
- excess.times { attrs.shift } if excess.positive?
+ if attrs.size > @span_limits.attribute_count_limit
+ n = @span_limits.attribute_count_limit
+ attrs.delete_if do |_key, _value|
+ n -= 1
+ n.negative?
+ end
+ end
+
truncate_attribute_values(attrs, @span_limits.attribute_length_limit)
nil
end
def truncate_attribute_values(attrs, attribute_length_limit)