Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Add tests #2

Merged
merged 2 commits into from
Sep 3, 2020
Merged

Add tests #2

merged 2 commits into from
Sep 3, 2020

Conversation

recurser
Copy link
Contributor

@recurser recurser commented Aug 28, 2020

Add tests

Clubhouse Story

How to test the PR

If tests pass, it works.

Deployment Notes

None.

@recurser recurser self-assigned this Aug 28, 2020
@recurser recurser force-pushed the dave/ch69519/add-tests branch 3 times, most recently from e8ba808 to 877214f Compare August 31, 2020 13:04
message: data&.to_json,
}.compact
end

Copy link
Contributor Author

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.

Copy link

@avokhmin avokhmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍

lib/trailer/storage/cloud_watch.rb Show resolved Hide resolved
@sr-devops sr-devops requested a review from avokhmin September 3, 2020 01:02
@recurser recurser merged commit 128b4f2 into master Sep 3, 2020
@recurser recurser deleted the dave/ch69519/add-tests branch September 3, 2020 01:41
Copy link

@avokhmin avokhmin left a 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?
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants