lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-0.12.1 vs lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-0.13.0
- old
+ new
@@ -118,18 +118,23 @@
# Record an exception during the execution of this span. Multiple exceptions
# can be recorded on a span.
#
# @param [Exception] exception The exception to be recorded
+ # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
+ # attributes One or more key:value pairs, where the keys must be
+ # strings and the values may be (array of) string, boolean or numeric
+ # type.
#
# @return [void]
- def record_exception(exception)
- add_event('exception',
- attributes: {
- 'exception.type' => exception.class.to_s,
- 'exception.message' => exception.message,
- 'exception.stacktrace' => exception.full_message(highlight: false, order: :top)
- })
+ def record_exception(exception, attributes: nil)
+ event_attributes = {
+ 'exception.type' => exception.class.to_s,
+ 'exception.message' => exception.message,
+ 'exception.stacktrace' => exception.full_message(highlight: false, order: :top)
+ }
+ event_attributes.merge!(attributes) unless attributes.nil?
+ add_event('exception', attributes: event_attributes)
end
# Sets the Status to the Span
#
# If used, this will override the default Span status. Default is OK.