deimos-ruby 2.0.13 → 2.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c18442a9ba85a0b6de4c3cdaee151727d7e7ba9ca70de8129b08a91ad1a100c
4
- data.tar.gz: 7db213f9a31a8775f6f23fd10098d284df59f5dbf4b040d0719b9fa10f5af6e6
3
+ metadata.gz: d6c9d3bcbf085821dc0be156389bd223dbce36ba8c34ff452612cf82ca3b3be4
4
+ data.tar.gz: fc9bf56f6ad566a9e197e50b5b167af620e9c0d6ec0fd9f50999059b7fded6ee
5
5
  SHA512:
6
- metadata.gz: 532e1eed51b376e568c1e7e9b424a65a29a7e339e8db91e3f3761328ff826e3ad45a8c12bddbb4155707610df3ab36bf90e1acfe6411b6829be6fe8e45453e75
7
- data.tar.gz: 29ca80e081b8c0699ee8b132c31d7ab27eb91f63dca808a03f8c7e3905a70a7f520964abc0631995b033c7bfc72d3581dd7d5dacd93d234b970ebbc92bd99837
6
+ metadata.gz: 88ac68371a699744e87fcc0c7e8a1294af1b02d4ff6973f95c1667c3754ac8fd0eeda65afddd966a4451058028409e3183e6bca112c553dbf7ac67f72929ffdd
7
+ data.tar.gz: 30f93b2f6aefbdf3b8554bb0a6b5bac53e6638a88adc75bdded31fde88b783ca6311fb50b652f9b8085d32da6175449181dd8229a1544018e0e1c7c51ddc158f
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ ## 2.0.15 - 2025-05-29
11
+
12
+ - Fix: Do not force data to JSON when logging payloads. This allows log formatters to handle the payloads on their own (e.g. adding additional fields).
13
+ - Fix: Add topic to "Publishing Messages" log message.
14
+
15
+ ## 2.0.14 - 2025-05-26
16
+
17
+ - Fix: Log actual payloads by default (was logging "null" for the payload).
18
+
10
19
  ## 2.0.13 - 2025-05-26
11
20
 
12
21
  - Fix: Outbox producer would crash if no Deimos producer was defined for the topic.
@@ -9,9 +9,10 @@ module Deimos
9
9
  # @param messages [Array<Hash>]
10
10
  # @return [void]
11
11
  def publish(producer_class:, messages:)
12
+ topic = producer_class.topic
12
13
  execute(producer_class: producer_class, messages: messages)
13
14
  message = ::Deimos::Logging.messages_log_text(producer_class.karafka_config.payload_log, messages)
14
- Deimos::Logging.log_info({message: 'Publishing Messages:'}.merge(message))
15
+ Deimos::Logging.log_info({message: "Publishing Messages for #{topic}:" }.merge(message))
15
16
  end
16
17
 
17
18
  # @param producer_class [Class<Deimos::Producer>]
@@ -5,10 +5,10 @@ module Deimos
5
5
  def log_add(method, msg)
6
6
  if Karafka.logger.respond_to?(:tagged)
7
7
  Karafka.logger.tagged('Deimos') do |logger|
8
- logger.send(method, msg.to_json)
8
+ logger.send(method, msg)
9
9
  end
10
10
  else
11
- Karafka.logger.send(method, msg.to_json)
11
+ Karafka.logger.send(method, msg)
12
12
  end
13
13
  end
14
14
 
@@ -42,7 +42,7 @@ module Deimos
42
42
  if m.respond_to?(:payload)
43
43
  m.payload
44
44
  elsif m[:label]
45
- m.dig(:label, :raw_payload)
45
+ m.dig(:label, :original_payload)
46
46
  else
47
47
  m[:payload]
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '2.0.13'
4
+ VERSION = '2.0.15'
5
5
  end
@@ -272,6 +272,50 @@ module ProducerTest
272
272
  }, '456', '4561')
273
273
  end
274
274
 
275
+ describe 'payload logging' do
276
+ context 'with default / full' do
277
+ it 'should log full payload' do
278
+ allow(Karafka.logger).to receive(:info)
279
+ MyProducerWithID.publish_list(
280
+ [
281
+ { 'test_id' => 'foo', 'some_int' => 123, :payload_key => 'key' },
282
+ { 'test_id' => 'foo2', 'some_int' => 123, :payload_key => 'key2' },
283
+ ]
284
+ )
285
+ expect(Karafka.logger).to have_received(:info).with(match_message({
286
+ message: 'Publishing Messages for my-topic-with-id:',
287
+ payloads: [
288
+ {
289
+ payload: { 'test_id' => 'foo', 'some_int' => 123 },
290
+ key: 'key'
291
+ },
292
+ {
293
+ payload: { 'test_id' => 'foo2', 'some_int' => 123 },
294
+ key: 'key2'
295
+ }
296
+ ]
297
+ }))
298
+ end
299
+ end
300
+
301
+ context 'with count' do
302
+ it 'should log only count' do
303
+ Deimos.karafka_config_for(topic: 'my-topic-with-id').payload_log :count
304
+ allow(Karafka.logger).to receive(:info)
305
+ MyProducerWithID.publish_list(
306
+ [
307
+ { 'test_id' => 'foo', 'some_int' => 123, :payload_key => 'key' },
308
+ { 'test_id' => 'foo2', 'some_int' => 123, :payload_key => 'key' }
309
+ ]
310
+ )
311
+ expect(Karafka.logger).to have_received(:info).with(match_message({
312
+ message: 'Publishing Messages for my-topic-with-id:',
313
+ payloads_count: 2
314
+ }))
315
+ end
316
+ end
317
+ end
318
+
275
319
  context 'with Schema Class payloads' do
276
320
  it 'should fail on invalid message with error handler' do
277
321
  expect(Deimos::ProducerMiddleware).to receive(:call).and_raise('OH NOES')
data/spec/spec_helper.rb CHANGED
@@ -343,3 +343,17 @@ RSpec.shared_context('with publish_backend') do
343
343
  end
344
344
  end
345
345
  end
346
+
347
+ RSpec::Matchers.define :match_message do |msg|
348
+ match do |actual|
349
+ begin
350
+ return false unless actual.is_a?(Hash)
351
+
352
+ actual[:payloads]&.each do |p|
353
+ p[:payload].delete('timestamp')
354
+ p[:payload].delete('message_id')
355
+ end
356
+ expect(actual).to match(a_hash_including(msg))
357
+ end
358
+ end
359
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-26 00:00:00.000000000 Z
11
+ date: 2025-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf