yes-core 2.4.4 → 2.5.0

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: 657f96d2dc9f3d762a91b42976783cfead117aae5be6473e547b4e1568cc8e83
4
+ data.tar.gz: 0c5b51b64f133b09cf14ef1d9c99fc7fcdd94f67f479f410dca443545b13ce56
5
5
  SHA512:
6
- metadata.gz: 17517ccd7d18cb454bd165631f13ed66c1632c7202336ccd4c0a7595fc016633e9723efccd78936470ebc0376da38d388577c22f46a2eb7c5f1029e4c7b4ad6f
7
- data.tar.gz: a871ad9ce20b63befd0215e9d170fc2d8c7d6a9abec352bd9e7e00ca3df58b7b5f29978e04aff42e8c84e96dd9a87af7cd4afe00d254e7f373d2c18eac18d1d4
6
+ metadata.gz: cecd619ffb8384612a3ad7a1640fbe6ed9f8d8b73b01f0da6bc8d1892bce474af92274444d8a3c7b16e1bfc622a1cadccbc793f51d61196dd48a57abbd3e0ec5
7
+ data.tar.gz: a8f5aee284c9e77715b839b395e4aefa99375275d76d47f9003e9aaf510cd77db88c5fc39c37046523247a01e958c8e1e689da8afc0044bb0928692bd311147c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.5.0] - 2026-10-08
4
+ - See root CHANGELOG.md for details.
5
+
6
+ ## [2.4.5] - 2026-09-23
7
+ - See root CHANGELOG.md for details.
8
+
3
9
  ## [2.4.4] - 2026-09-15
4
10
  - See root CHANGELOG.md for details.
5
11
 
@@ -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(
@@ -104,6 +104,15 @@ module Yes
104
104
  # #verify_token(token) and #error_classes (returns array of error classes).
105
105
  attr_accessor :auth_adapter
106
106
 
107
+ # Error classes an API controller should rescue as authentication failures: the gem's own
108
+ # AuthenticationError plus the classes of the configured auth adapter (if any). Computed on
109
+ # each call because the adapter is assigned in an initializer after controllers may load.
110
+ #
111
+ # @return [Array<Class>] deduplicated error classes
112
+ def auth_error_classes
113
+ [Yes::Core::AuthenticationError, *auth_adapter&.error_classes].uniq
114
+ end
115
+
107
116
  # Initializes a new configuration instance with nested hashes for class storage.
108
117
  def initialize
109
118
  @registered_classes = Hash.new do |h, k|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yes
4
4
  module Core
5
- VERSION = '2.4.4'
5
+ VERSION = '2.5.0'
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.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Ritsche