yes-core 2.4.2 → 2.4.4
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9fb1cb54a16eac6310fbbe1bc287d705c4fa0c92cbcb3ec55ae8e763efafaea
|
|
4
|
+
data.tar.gz: 7e218f6cbbb4fc56c1b067e0c1b00cae090bf932692b04ed1a8b5f5255c0236d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17517ccd7d18cb454bd165631f13ed66c1632c7202336ccd4c0a7595fc016633e9723efccd78936470ebc0376da38d388577c22f46a2eb7c5f1029e4c7b4ad6f
|
|
7
|
+
data.tar.gz: a871ad9ce20b63befd0215e9d170fc2d8c7d6a9abec352bd9e7e00ca3df58b7b5f29978e04aff42e8c84e96dd9a87af7cd4afe00d254e7f373d2c18eac18d1d4
|
data/CHANGELOG.md
CHANGED
|
@@ -35,6 +35,7 @@ module Yes
|
|
|
35
35
|
def call(group_name, payload, guards: true, metadata: nil)
|
|
36
36
|
prepared = prepare_payload(payload, metadata)
|
|
37
37
|
cmd = command_utilities.build_group_command(group_name, prepared)
|
|
38
|
+
otl_record_command(cmd)
|
|
38
39
|
guard_evaluator_class = command_utilities.fetch_guard_evaluator_class_for_group(group_name)
|
|
39
40
|
|
|
40
41
|
ReadModelRecoveryService.check_and_recover_with_retries(read_model, aggregate:) if aggregate.class.read_model_enabled?
|
|
@@ -49,6 +50,17 @@ module Yes
|
|
|
49
50
|
|
|
50
51
|
attr_reader :aggregate, :command_utilities, :read_model
|
|
51
52
|
|
|
53
|
+
# Records which command group the span ran; see CommandHandler#otl_record_command.
|
|
54
|
+
#
|
|
55
|
+
# @param cmd [Object] the built command group
|
|
56
|
+
# @return [void]
|
|
57
|
+
def otl_record_command(cmd)
|
|
58
|
+
name = cmd.class.name
|
|
59
|
+
return if name.nil?
|
|
60
|
+
|
|
61
|
+
self.class.current_span&.add_attributes({ CommandHandler::COMMAND_ATTRIBUTE => name })
|
|
62
|
+
end
|
|
63
|
+
|
|
52
64
|
# Prepares the payload before constructing the group command.
|
|
53
65
|
# Mirrors the metadata-injection logic in {CommandHandler#prepare_payload}.
|
|
54
66
|
#
|
|
@@ -11,6 +11,14 @@ module Yes
|
|
|
11
11
|
# response = handler.call(:approve_documents, { document_ids: '123', another: 'value' })
|
|
12
12
|
#
|
|
13
13
|
class CommandHandler
|
|
14
|
+
# Span attribute naming the command that ran. The span keeps a fixed name so its
|
|
15
|
+
# latency histogram stays one series per service; this is how the command is identified.
|
|
16
|
+
#
|
|
17
|
+
# Not the bare `command`: CommandCerbosAuthorizer already puts the serialised command
|
|
18
|
+
# on an attribute of that name, and a metrics pipeline that exports span attributes by
|
|
19
|
+
# name cannot tell the two apart. It would export the payload, one series per payload.
|
|
20
|
+
COMMAND_ATTRIBUTE = 'command.name'
|
|
21
|
+
|
|
14
22
|
include Yes::Core::OpenTelemetry::Trackable
|
|
15
23
|
|
|
16
24
|
# Initializes a new CommandHandler
|
|
@@ -32,6 +40,7 @@ module Yes
|
|
|
32
40
|
def call(command_name, payload, guards: true, metadata: nil)
|
|
33
41
|
prepared_payload = prepare_payload(command_name, payload, metadata)
|
|
34
42
|
cmd = command_utilities.build_command(command_name, prepared_payload)
|
|
43
|
+
otl_record_command(cmd)
|
|
35
44
|
|
|
36
45
|
guard_evaluator_class = command_utilities.fetch_guard_evaluator_class(command_name)
|
|
37
46
|
|
|
@@ -51,6 +60,18 @@ module Yes
|
|
|
51
60
|
|
|
52
61
|
attr_reader :aggregate, :command_utilities, :read_model
|
|
53
62
|
|
|
63
|
+
# Records which command the span ran. The span itself keeps a fixed name so its latency
|
|
64
|
+
# histogram stays a single series per service; the command goes on an attribute instead.
|
|
65
|
+
#
|
|
66
|
+
# @param cmd [Object] the built command
|
|
67
|
+
# @return [void]
|
|
68
|
+
def otl_record_command(cmd)
|
|
69
|
+
name = cmd.class.name
|
|
70
|
+
return if name.nil?
|
|
71
|
+
|
|
72
|
+
self.class.current_span&.add_attributes({ COMMAND_ATTRIBUTE => name })
|
|
73
|
+
end
|
|
74
|
+
|
|
54
75
|
# Prepares the command payload
|
|
55
76
|
#
|
|
56
77
|
# @param command_name [Symbol] The command name
|
data/lib/yes/core/version.rb
CHANGED