-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
e8ba808
to
877214f
Compare
message: data&.to_json, | ||
}.compact | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just putting methods in alphabetical order - no logic changes.
877214f
to
078124e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lib/trailer/concern.rb
Outdated
@@ -27,7 +28,7 @@ def trace_event(event, resource = nil, **tags, &block) # rubocop:disable Metrics | |||
end | |||
elsif resource.respond_to?(:to_h) | |||
# This handles other types of data, such as GraphQL input objects. | |||
resource.to_h.stringify_keys.each do |key, value| | |||
resource.to_h.transform_keys(&:to_s).each do |key, value| | |||
tags[key] ||= value if key.to_s.match?(Trailer.config.auto_tag_fields) || Trailer.config.tag_fields.include?(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags[key] ||= value if key.to_s.match?(Trailer.config.auto_tag_fields) || Trailer.config.tag_fields.include?(key) | |
tags[key] ||= value if key.match?(Trailer.config.auto_tag_fields) || Trailer.config.tag_fields.include?(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: maybe here better to use a symbols too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# | ||
# @param data [Hash] A key-value hash of trace data to write to storage. | ||
def write(data) | ||
return if data.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe:
def write(data)
return if data.nil? || data.empty?
messages << {
timestamp: (Time.now.utc.to_f.round(3) * 1000).to_i,
message: data.to_json,
}
end
Add tests
Clubhouse Story
How to test the PR
If tests pass, it works.
Deployment Notes
None.