Skip to content

Commit f2b9164

Browse files
committed
update instrument syntax
1 parent f0881d2 commit f2b9164

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

lib/idempotency.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def use_cache(request, request_identifiers, lock_duration: nil, action: nil)
7171
duration_start = Process.clock_gettime(::Process::CLOCK_MONOTONIC)
7272
action_name = action || "#{request.request_method}:#{request.path}"
7373

74-
with_apm_instrumentation('process_action.idempotency.use_cache', action_name) do
74+
with_apm_instrumentation('idempotency.use_cache', action_name) do
7575
return yield unless cache_request?(request)
7676

7777
request_headers = request.env
@@ -157,24 +157,18 @@ def with_apm_instrumentation(name, action, &block)
157157
# Wrap with Sentry if enabled
158158
if config.observability.sentry_enabled && defined?(Sentry)
159159
instrumented_block = lambda do
160-
transaction = Sentry.start_transaction(name: name, op: 'idempotency')
161-
transaction.set_data("action", action)
162-
Sentry.get_current_scope.set_span(transaction)
163-
164-
begin
160+
Sentry.with_child_span(op: name, description: action) do |_span|
165161
block.call
166-
rescue StandardError => e
167-
Sentry.capture_exception(e)
168-
raise
169-
ensure
170-
transaction.finish
171162
end
163+
rescue StandardError => e
164+
Sentry.capture_exception(e)
165+
raise
172166
end
173167
end
174168

175169
# Wrap with AppSignal if enabled (outermost layer)
176170
if config.observability.appsignal_enabled && defined?(Appsignal)
177-
Appsignal.monitor_transaction(name, action: action) do
171+
Appsignal.instrument(name, action: action) do
178172
instrumented_block.call
179173
rescue StandardError => e
180174
Appsignal.set_error(e)

0 commit comments

Comments
 (0)