@@ -13,16 +13,11 @@ defmodule Commanded.OpenTelemetry.EventStore do
1313 @ tracer_id __MODULE__
1414
1515 @ events ~w(
16- ack_event
1716 append_to_stream
1817 delete_snapshot
19- delete_subscription
2018 read_snapshot
2119 record_snapshot
2220 stream_forward
23- subscribe
24- subscribe_to
25- unsubscribe
2621 ) a
2722
2823 def setup do
@@ -53,7 +48,7 @@ defmodule Commanded.OpenTelemetry.EventStore do
5348 action_name = to_string ( action )
5449 { adapter , adapter_meta } = fetch_event_store_adapter ( meta [ :application ] )
5550 event_store_name = event_store_name ( adapter_meta )
56- destination_name = to_destination_name ( event_store_name )
51+ destination_name = Helpers . to_destination_name ( event_store_name )
5752 source_uuid = extract_source_uuid ( meta )
5853 connection_config = lookup_connection_config ( adapter , event_store_name )
5954
@@ -65,14 +60,17 @@ defmodule Commanded.OpenTelemetry.EventStore do
6560 { CommandedAttributes . commanded_application ( ) , meta [ :application ] }
6661 ]
6762 |> maybe_add_db_system ( adapter )
68- |> maybe_add_operation_type ( operation_type )
69- |> maybe_add_destination_name ( destination_name )
70- |> maybe_add_stream_uuid ( meta [ :stream_uuid ] )
71- |> maybe_add_expected_version ( meta [ :expected_version ] )
72- |> maybe_add_subscription_name ( meta [ :subscription_name ] )
73- |> maybe_add_source_uuid ( source_uuid )
63+ |> Helpers . maybe_add_operation_type ( operation_type )
64+ |> Helpers . maybe_add_destination_name ( destination_name )
65+ |> Helpers . maybe_add_stream_uuid ( meta [ :stream_uuid ] )
66+ |> Helpers . maybe_add_expected_version ( meta [ :expected_version ] )
67+ |> Helpers . maybe_add_event_count ( meta [ :event_count ] )
68+ |> Helpers . maybe_add_subscription_name ( meta [ :subscription_name ] )
69+ |> Helpers . maybe_add_source_uuid ( source_uuid )
7470 |> maybe_add_start_from ( meta [ :start_from ] )
75- |> Helpers . maybe_add_connection_attributes ( connection_config , peer_service: destination_name )
71+ |> maybe_add_start_version ( meta [ :start_version ] )
72+ |> maybe_add_read_batch_size ( meta [ :read_batch_size ] )
73+ |> Helpers . maybe_add_connection_attributes ( connection_config )
7674
7775 span_name =
7876 case destination_name do
@@ -143,55 +141,25 @@ defmodule Commanded.OpenTelemetry.EventStore do
143141
144142 defp operation_type_for ( :append_to_stream ) , do: :publish
145143 defp operation_type_for ( :stream_forward ) , do: :receive
146- defp operation_type_for ( :subscribe ) , do: :receive
147- defp operation_type_for ( :subscribe_to ) , do: :receive
148- defp operation_type_for ( :ack_event ) , do: :settle
149144 defp operation_type_for ( :delete_snapshot ) , do: nil
150- defp operation_type_for ( :delete_subscription ) , do: nil
151145 defp operation_type_for ( :read_snapshot ) , do: :receive
152146 defp operation_type_for ( :record_snapshot ) , do: :publish
153- defp operation_type_for ( :unsubscribe ) , do: nil
154147 defp operation_type_for ( _ ) , do: nil
155148
156- defp maybe_add_operation_type ( attrs , nil ) , do: attrs
157-
158- defp maybe_add_operation_type ( attrs , type ) ,
159- do: [ { MessagingAttributes . messaging_operation_type ( ) , type } | attrs ]
160-
161- defp maybe_add_destination_name ( attrs , nil ) , do: attrs
162-
163- defp maybe_add_destination_name ( attrs , destination_name ) ,
164- do: [ { MessagingAttributes . messaging_destination_name ( ) , destination_name } | attrs ]
165-
166- defp maybe_add_stream_uuid ( attrs , nil ) , do: attrs
167-
168- defp maybe_add_stream_uuid ( attrs , stream_uuid ) ,
169- do: [ { CommandedAttributes . commanded_stream_uuid ( ) , stream_uuid } | attrs ]
170-
171- defp maybe_add_expected_version ( attrs , nil ) , do: attrs
172-
173- defp maybe_add_expected_version ( attrs , expected_version ) ,
174- do: [ { CommandedAttributes . commanded_expected_version ( ) , expected_version } | attrs ]
175-
176- defp maybe_add_subscription_name ( attrs , nil ) , do: attrs
149+ defp maybe_add_start_from ( attrs , nil ) , do: attrs
177150
178- defp maybe_add_subscription_name ( attrs , name ) do
179- [
180- { MessagingAttributes . messaging_destination_subscription_name ( ) , name } ,
181- { CommandedAttributes . commanded_subscription_name ( ) , name }
182- | attrs
183- ]
184- end
151+ defp maybe_add_start_from ( attrs , start_from ) ,
152+ do: [ { CommandedAttributes . commanded_start_from ( ) , to_start_from_attr ( start_from ) } | attrs ]
185153
186- defp maybe_add_source_uuid ( attrs , nil ) , do: attrs
154+ defp maybe_add_start_version ( attrs , nil ) , do: attrs
187155
188- defp maybe_add_source_uuid ( attrs , source_uuid ) ,
189- do: [ { CommandedAttributes . commanded_source_uuid ( ) , source_uuid } | attrs ]
156+ defp maybe_add_start_version ( attrs , version ) ,
157+ do: [ { CommandedAttributes . commanded_stream_start_version ( ) , version } | attrs ]
190158
191- defp maybe_add_start_from ( attrs , nil ) , do: attrs
159+ defp maybe_add_read_batch_size ( attrs , nil ) , do: attrs
192160
193- defp maybe_add_start_from ( attrs , start_from ) ,
194- do: [ { CommandedAttributes . commanded_start_from ( ) , to_start_from_attr ( start_from ) } | attrs ]
161+ defp maybe_add_read_batch_size ( attrs , size ) ,
162+ do: [ { CommandedAttributes . commanded_stream_batch_size ( ) , size } | attrs ]
195163
196164 # Extract source_uuid from metadata or nested snapshot struct (record_snapshot operation)
197165 defp extract_source_uuid ( % { source_uuid: uuid } ) when is_binary ( uuid ) , do: uuid
@@ -242,11 +210,6 @@ defmodule Commanded.OpenTelemetry.EventStore do
242210
243211 defp event_store_name ( _ ) , do: nil
244212
245- defp to_destination_name ( nil ) , do: nil
246- defp to_destination_name ( name ) when is_binary ( name ) , do: name
247- defp to_destination_name ( name ) when is_atom ( name ) , do: inspect ( name )
248- defp to_destination_name ( _ ) , do: nil
249-
250213 defp to_start_from_attr ( nil ) , do: nil
251214 defp to_start_from_attr ( atom ) when is_atom ( atom ) , do: to_string ( atom )
252215 defp to_start_from_attr ( other ) , do: other
0 commit comments