diff --git a/CHANGELOG.md b/CHANGELOG.md index f81fe26..88ee978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - yyyy-mm-dd +## [6.4.3] - 2024-05-16 + +### Fixed + +- replace `/` with `-` in label `name` in outbox_last_stored_event_id / outbox_created_counter + ## [6.4.2] - 2024-05-07 ### Fixed diff --git a/app/interactors/sbmt/outbox/base_create_item.rb b/app/interactors/sbmt/outbox/base_create_item.rb index beca850..8d3a8e6 100644 --- a/app/interactors/sbmt/outbox/base_create_item.rb +++ b/app/interactors/sbmt/outbox/base_create_item.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "sbmt/outbox/metrics/utils" + module Sbmt module Outbox class BaseCreateItem < Outbox::DryInteractor @@ -41,14 +43,14 @@ def track_last_stored_id(item_id, partition) Yabeda .outbox .last_stored_event_id - .set({type: box_type, name: box_name, owner: owner, partition: partition}, item_id) + .set({type: box_type, name: Sbmt::Outbox::Metrics::Utils.metric_safe(box_name), owner: owner, partition: partition}, item_id) end def track_counter(partition) Yabeda .outbox .created_counter - .increment({type: box_type, name: box_name, owner: owner, partition: partition}, by: 1) + .increment({type: box_type, name: Sbmt::Outbox::Metrics::Utils.metric_safe(box_name), owner: owner, partition: partition}, by: 1) end end end diff --git a/lib/sbmt/outbox/version.rb b/lib/sbmt/outbox/version.rb index 2d2482e..2467250 100644 --- a/lib/sbmt/outbox/version.rb +++ b/lib/sbmt/outbox/version.rb @@ -2,6 +2,6 @@ module Sbmt module Outbox - VERSION = "6.4.2" + VERSION = "6.4.3" end end diff --git a/spec/interactors/sbmt/outbox/create_inbox_item_spec.rb b/spec/interactors/sbmt/outbox/create_inbox_item_spec.rb index b807f14..584669c 100644 --- a/spec/interactors/sbmt/outbox/create_inbox_item_spec.rb +++ b/spec/interactors/sbmt/outbox/create_inbox_item_spec.rb @@ -17,7 +17,9 @@ end it "tracks Yabeda metrics" do - expect { result }.to update_yabeda_gauge(Yabeda.outbox.last_stored_event_id) + expect { result } + .to update_yabeda_gauge(Yabeda.outbox.last_stored_event_id).with_tags(name: "inbox_item", type: :inbox, owner: nil, partition: 0) + .and increment_yabeda_counter(Yabeda.outbox.created_counter).with_tags(name: "inbox_item", type: :inbox, owner: nil, partition: 0) end context "when got errors" do @@ -26,7 +28,9 @@ end it "does not track Yabeda metrics" do - expect { result }.not_to update_yabeda_gauge(Yabeda.outbox.last_stored_event_id) + expect { result } + .to not_update_yabeda_gauge(Yabeda.outbox.last_stored_event_id) + .and not_increment_yabeda_counter(Yabeda.outbox.created_counter) end it "returns errors" do diff --git a/spec/interactors/sbmt/outbox/create_outbox_item_spec.rb b/spec/interactors/sbmt/outbox/create_outbox_item_spec.rb index c28752a..b44f11a 100644 --- a/spec/interactors/sbmt/outbox/create_outbox_item_spec.rb +++ b/spec/interactors/sbmt/outbox/create_outbox_item_spec.rb @@ -1,23 +1,26 @@ # frozen_string_literal: true describe Sbmt::Outbox::CreateOutboxItem do - subject(:result) { described_class.call(OutboxItem, attributes: attributes) } + subject(:result) { described_class.call(Combined::OutboxItem, attributes: attributes) } let(:attributes) do { payload: "test", - event_key: 10 + event_key: 10, + event_name: "order_created" } end it "creates a record" do - expect { result }.to change(OutboxItem, :count).by(1) + expect { result }.to change(Combined::OutboxItem, :count).by(1) expect(result).to be_success - expect(result.value!).to have_attributes(bucket: 2) + expect(result.value!).to have_attributes(bucket: 1) end it "tracks Yabeda metrics" do - expect { result }.to update_yabeda_gauge(Yabeda.outbox.last_stored_event_id) + expect { result } + .to update_yabeda_gauge(Yabeda.outbox.last_stored_event_id).with_tags(name: "combined-outbox_item", type: :outbox, owner: nil, partition: 1) + .and increment_yabeda_counter(Yabeda.outbox.created_counter).with_tags(name: "combined-outbox_item", type: :outbox, owner: nil, partition: 1) end context "when got errors" do @@ -26,24 +29,26 @@ end it "does not track Yabeda metrics" do - expect { result }.not_to update_yabeda_gauge(Yabeda.outbox.last_stored_event_id) + expect { result } + .to not_update_yabeda_gauge(Yabeda.outbox.last_stored_event_id) + .and not_increment_yabeda_counter(Yabeda.outbox.created_counter) end it "returns errors" do - expect { result }.not_to change(OutboxItem, :count) + expect { result }.not_to change(Combined::OutboxItem, :count) expect(result).not_to be_success end end context "when partition by custom key" do - subject(:result) { described_class.call(InboxItem, attributes: attributes, partition_by: partition_by) } + subject(:result) { described_class.call(Combined::OutboxItem, attributes: attributes, partition_by: partition_by) } let(:partition_by) { 9 } it "creates a record" do - expect { result }.to change(InboxItem, :count).by(1) + expect { result }.to change(Combined::OutboxItem, :count).by(1) expect(result).to be_success - expect(result.value!).to have_attributes(bucket: 1) + expect(result.value!).to have_attributes(bucket: 3) end end end