@@ -12,6 +12,7 @@ defmodule Sentry.TelemetryProcessor do
1212
1313 * Error Buffer - for error events (critical priority)
1414 * Check-in Buffer - for cron check-ins (high priority)
15+ * Transaction Buffer - for performance transactions (medium priority)
1516 * Log Buffer - for log entries (low priority)
1617 * Scheduler - weighted round-robin scheduler with integrated transport queue
1718
@@ -23,6 +24,9 @@ defmodule Sentry.TelemetryProcessor do
2324 # Add check-ins to the buffer
2425 TelemetryProcessor.add(processor, %Sentry.CheckIn{...})
2526
27+ # Add transactions to the buffer
28+ TelemetryProcessor.add(processor, %Sentry.Transaction{...})
29+
2630 # Add log events to the buffer
2731 TelemetryProcessor.add(processor, %Sentry.LogEvent{...})
2832
@@ -35,7 +39,7 @@ defmodule Sentry.TelemetryProcessor do
3539 use Supervisor
3640
3741 alias Sentry.Telemetry . { Buffer , Category , Scheduler }
38- alias Sentry . { CheckIn , Event , LogEvent }
42+ alias Sentry . { CheckIn , Event , LogEvent , Transaction }
3943
4044 @ default_name __MODULE__
4145
@@ -91,7 +95,7 @@ defmodule Sentry.TelemetryProcessor do
9195
9296 Returns `:ok`.
9397 """
94- @ spec add ( Event . t ( ) | CheckIn . t ( ) | LogEvent . t ( ) ) :: :ok
98+ @ spec add ( Event . t ( ) | CheckIn . t ( ) | Transaction . t ( ) | LogEvent . t ( ) ) :: :ok
9599 def add ( % Event { } = item ) do
96100 add ( processor_name ( ) , item )
97101 end
@@ -100,6 +104,10 @@ defmodule Sentry.TelemetryProcessor do
100104 add ( processor_name ( ) , item )
101105 end
102106
107+ def add ( % Transaction { } = item ) do
108+ add ( processor_name ( ) , item )
109+ end
110+
103111 def add ( % LogEvent { } = item ) do
104112 add ( processor_name ( ) , item )
105113 end
@@ -111,7 +119,8 @@ defmodule Sentry.TelemetryProcessor do
111119
112120 Returns `:ok`.
113121 """
114- @ spec add ( Supervisor . supervisor ( ) , Event . t ( ) | CheckIn . t ( ) | LogEvent . t ( ) ) :: :ok
122+ @ spec add ( Supervisor . supervisor ( ) , Event . t ( ) | CheckIn . t ( ) | Transaction . t ( ) | LogEvent . t ( ) ) ::
123+ :ok
115124 def add ( processor , % Event { } = item ) when is_atom ( processor ) do
116125 Buffer . add ( buffer_name ( processor , :error ) , item )
117126 Scheduler . signal ( scheduler_name ( processor ) )
@@ -140,6 +149,20 @@ defmodule Sentry.TelemetryProcessor do
140149 :ok
141150 end
142151
152+ def add ( processor , % Transaction { } = item ) when is_atom ( processor ) do
153+ Buffer . add ( buffer_name ( processor , :transaction ) , item )
154+ Scheduler . signal ( scheduler_name ( processor ) )
155+ :ok
156+ end
157+
158+ def add ( processor , % Transaction { } = item ) do
159+ buffer = get_buffer ( processor , :transaction )
160+ Buffer . add ( buffer , item )
161+ scheduler = get_scheduler ( processor )
162+ Scheduler . signal ( scheduler )
163+ :ok
164+ end
165+
143166 def add ( processor , % LogEvent { } = item ) when is_atom ( processor ) do
144167 Buffer . add ( buffer_name ( processor , :log ) , item )
145168 Scheduler . signal ( scheduler_name ( processor ) )
@@ -187,7 +210,7 @@ defmodule Sentry.TelemetryProcessor do
187210 Returns the buffer pid for a given category.
188211 """
189212 @ spec get_buffer ( Supervisor . supervisor ( ) , Category . t ( ) ) :: pid ( )
190- def get_buffer ( processor , category ) when category in [ :error , :check_in , :log ] do
213+ def get_buffer ( processor , category ) when category in [ :error , :check_in , :transaction , : log] do
191214 children = Supervisor . which_children ( processor )
192215 buffer_id = buffer_id ( category )
193216
@@ -217,7 +240,7 @@ defmodule Sentry.TelemetryProcessor do
217240 Returns 0 if the processor is not running.
218241 """
219242 @ spec buffer_size ( Category . t ( ) ) :: non_neg_integer ( )
220- def buffer_size ( category ) when category in [ :error , :check_in , :log ] do
243+ def buffer_size ( category ) when category in [ :error , :check_in , :transaction , : log] do
221244 buffer_size ( processor_name ( ) , category )
222245 end
223246
@@ -227,7 +250,7 @@ defmodule Sentry.TelemetryProcessor do
227250 Returns 0 if the processor is not running.
228251 """
229252 @ spec buffer_size ( Supervisor . supervisor ( ) , Category . t ( ) ) :: non_neg_integer ( )
230- def buffer_size ( processor , category ) when category in [ :error , :check_in , :log ] do
253+ def buffer_size ( processor , category ) when category in [ :error , :check_in , :transaction , : log] do
231254 case safe_get_buffer ( processor , category ) do
232255 { :ok , buffer } -> Buffer . size ( buffer )
233256 :error -> 0
@@ -290,6 +313,7 @@ defmodule Sentry.TelemetryProcessor do
290313 buffers: % {
291314 error: Map . fetch! ( buffer_names , :error ) ,
292315 check_in: Map . fetch! ( buffer_names , :check_in ) ,
316+ transaction: Map . fetch! ( buffer_names , :transaction ) ,
293317 log: Map . fetch! ( buffer_names , :log )
294318 } ,
295319 name: scheduler_name ( processor_name ) ,
@@ -310,6 +334,7 @@ defmodule Sentry.TelemetryProcessor do
310334
311335 defp buffer_id ( :error ) , do: :error_buffer
312336 defp buffer_id ( :check_in ) , do: :check_in_buffer
337+ defp buffer_id ( :transaction ) , do: :transaction_buffer
313338 defp buffer_id ( :log ) , do: :log_buffer
314339
315340 @ doc false
0 commit comments