Skip to content

Commit

Permalink
FIX: Ensure truncated messages can still be merged when they're similar
Browse files Browse the repository at this point in the history
  • Loading branch information
OsamaSayegh committed Jan 23, 2020
1 parent d0d967f commit 275a818
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/logster/base_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ def report(severity, progname, msg, opts = {})
similar = nil

if Logster.config.allow_grouping
message.apply_message_size_limit(
Logster.config.maximum_message_size_bytes,
gems_dir: Logster.config.gems_dir
)
key = self.similar_key(message)
similar = get(key, load_env: false) if key
end
Expand Down
12 changes: 12 additions & 0 deletions test/logster/test_redis_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,18 @@ def test_latest_doesnt_include_rows_that_are_removed_from_grouping_patterns_due_
Logster::Group.remove_instance_variable(:@max_size)
end

def test_truncated_messages_when_they_are_similar_can_still_be_merged
config_reset(allow_grouping: true) do
backtrace = "a" * Logster.config.maximum_message_size_bytes
title = "sasasas"
msg = @store.report(Logger::WARN, '', title, backtrace: backtrace.dup)
msg2 = @store.report(Logger::WARN, '', title, backtrace: backtrace.dup)
assert_equal(msg.key, msg2.key)
assert_operator(msg.to_json(exclude_env: true).bytesize, :<=, Logster.config.maximum_message_size_bytes)
assert_operator(msg.backtrace.size, :<, backtrace.size)
end
end

private

def config_reset(configs)
Expand Down

0 comments on commit 275a818

Please sign in to comment.