From f47e29fae9e964ce2aebb866aaebab01f2a0045b Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Fri, 8 Sep 2023 00:01:20 +0200 Subject: [PATCH] Fix missing sentry breadcrumb for websocket connection It seems like we are still not setting the Sentry hub correctly. Therefore, we just use the hub passed with the span to add the breadcrumbs. --- lib/runner/connection.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/runner/connection.rb b/lib/runner/connection.rb index f41bf9e0..3df78c80 100644 --- a/lib/runner/connection.rb +++ b/lib/runner/connection.rb @@ -147,7 +147,7 @@ class Runner::Connection def on_close(event, sentry_span) Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Closing connection to #{@socket.url} with status: #{@status}" } - record_sentry_breadcrumb(event) + record_sentry_breadcrumb(sentry_span, event) end_sentry_span(sentry_span, event) flush_buffers @@ -278,7 +278,7 @@ class Runner::Connection sentry_span.finish(end_timestamp: Sentry.utc_now.to_f) end - def record_sentry_breadcrumb(event) + def record_sentry_breadcrumb(sentry_span, event) return unless Sentry.initialized? && Sentry.configuration.breadcrumbs_logger.include?(:http_logger) crumb = Sentry::Breadcrumb.new( @@ -286,10 +286,11 @@ class Runner::Connection category: SENTRY_BREADCRUMB_CATEGORY, type: :info, data: { - status: event.code.to_i, + close_status: event.code.to_i, + connection_status: @status, url: @socket.url, } ) - Sentry.add_breadcrumb(crumb) + sentry_span.transaction.hub.add_breadcrumb(crumb) end end