yes-core 2.4.4 → 2.4.5

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: d9fb1cb54a16eac6310fbbe1bc287d705c4fa0c92cbcb3ec55ae8e763efafaea
4
- data.tar.gz: 7e218f6cbbb4fc56c1b067e0c1b00cae090bf932692b04ed1a8b5f5255c0236d
3
+ metadata.gz: 1015d6ea5414383b562af2eee6665410cbf5e434e849015bc679eb30c7677a28
4
+ data.tar.gz: cba436f63754c8d5b74c371d83558f4deb16353fbde8d502a1e45d757971f161
5
5
  SHA512:
6
- metadata.gz: 17517ccd7d18cb454bd165631f13ed66c1632c7202336ccd4c0a7595fc016633e9723efccd78936470ebc0376da38d388577c22f46a2eb7c5f1029e4c7b4ad6f
7
- data.tar.gz: a871ad9ce20b63befd0215e9d170fc2d8c7d6a9abec352bd9e7e00ca3df58b7b5f29978e04aff42e8c84e96dd9a87af7cd4afe00d254e7f373d2c18eac18d1d4
6
+ metadata.gz: 3d9abb7576fb11421f5d8a85e67c421947659d70eb73d45317208f8f08a616778cba920fe431e6798d2ffcbeee24085c89aea89659b4579b74afa84464630cf0
7
+ data.tar.gz: fb8e7e151455887d7c7175778508be1c357c47e517ed170bca6e6f535bbf338c32c50698e6e8bdc37ab7b991f9f3e7a912aefc7bd3c12eb3e0dc3310d59f6258
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.4.5] - 2026-09-23
4
+ - See root CHANGELOG.md for details.
5
+
3
6
  ## [2.4.4] - 2026-09-15
4
7
  - See root CHANGELOG.md for details.
5
8
 
@@ -7,6 +7,13 @@ module Yes
7
7
  class EventPublisher
8
8
  include Yes::Core::OpenTelemetry::Trackable
9
9
 
10
+ # Prefix of the span attributes that carry single event metadata entries
11
+ METADATA_ATTRIBUTE_PREFIX = 'event.metadata.'
12
+ # Metadata value types that are recorded as their own span attribute. The OpenTelemetry SDK
13
+ # rejects other numerics (e.g. BigDecimal), so only Integer and Float are listed.
14
+ SCALAR_METADATA_TYPES = [String, Symbol, Integer, Float, TrueClass, FalseClass].freeze
15
+ private_constant :METADATA_ATTRIBUTE_PREFIX, :SCALAR_METADATA_TYPES
16
+
10
17
  # Value object containing aggregate data needed for event publication
11
18
  AggregateEventPublicationData = Struct.new(:id, :context, :name, :revision, keyword_init: true) do
12
19
  def self.from_aggregate(aggregate)
@@ -153,16 +160,34 @@ module Yes
153
160
  meta
154
161
  end
155
162
 
163
+ # Records the event on the current span: type, data and metadata as JSON, plus every
164
+ # scalar top-level metadata entry as its own `event.metadata.<key>` attribute, so tracing
165
+ # backends can derive metrics dimensioned by a metadata key. Nil, hash and array values
166
+ # are left out; they remain readable in the JSON attribute.
167
+ #
168
+ # @param event [PgEventstore::Event] The event about to be published
169
+ # @return [void]
156
170
  def otl_record_event_data(event)
157
171
  self.class.current_span&.add_attributes(
158
172
  {
159
173
  'event.type' => event.type,
160
174
  'event.data' => event.data.to_json,
161
- 'event.metadata' => event.metadata.to_json
175
+ 'event.metadata' => event.metadata.to_json,
176
+ **scalar_metadata_attributes(event.metadata)
162
177
  }
163
178
  )
164
179
  end
165
180
 
181
+ # @param metadata [Hash] The event metadata
182
+ # @return [Hash{String => String, Numeric, Boolean}] Scalar metadata entries keyed by span attribute name
183
+ def scalar_metadata_attributes(metadata)
184
+ metadata.each_with_object({}) do |(key, value), attributes|
185
+ next unless SCALAR_METADATA_TYPES.any? { value.is_a?(_1) }
186
+
187
+ attributes["#{METADATA_ATTRIBUTE_PREFIX}#{key}"] = value.is_a?(Symbol) ? value.to_s : value
188
+ end
189
+ end
190
+
166
191
  def otl_record_response(result)
167
192
  if ENV['STATSD_ADDR'].present?
168
193
  StatsD.increment(
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yes
4
4
  module Core
5
- VERSION = '2.4.4'
5
+ VERSION = '2.4.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yes-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Ritsche