lib/opentelemetry/common/utilities.rb in opentelemetry-common-0.19.3 vs lib/opentelemetry/common/utilities.rb in opentelemetry-common-0.19.5
- old
+ new
@@ -70,9 +70,20 @@
# @return [String]
def truncate(string, size)
string.size > size ? "#{string[0...size - 3]}..." : string
end
+ def truncate_attribute_value(value, limit)
+ case value
+ when Array
+ value.map { |x| truncate_attribute_value(x, limit) }
+ when String
+ truncate(value, limit)
+ else
+ value
+ end
+ end
+
def untraced
OpenTelemetry::Trace.with_span(OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new)) { yield }
end
# Returns a URL string with userinfo removed.