Skip to content

Commit ef05dba

Browse files
committed
test(active_job): refactor Sentry configuration setup and add db span tracking
1 parent 3916d0f commit ef05dba

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

sentry-rails/spec/active_job/shared_examples/tracing/consumer_transaction.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def perform
1616
end
1717

1818
context "with traces_sample_rate = 1.0" do
19-
before { Sentry.configuration.traces_sample_rate = 1.0 }
19+
let(:configure_sentry) { proc { |config| config.traces_sample_rate = 1.0 } }
2020

2121
it "captures a successful transaction with name, op, origin, source, and ok status" do
2222
successful_job.perform_later
@@ -32,6 +32,23 @@ def perform
3232
expect(transaction.contexts.dig(:trace, :status)).to eq("ok")
3333
end
3434

35+
it "records a db.sql.active_record child span when the job performs a query" do
36+
query_job = job_fixture do
37+
def perform
38+
Post.all.to_a
39+
end
40+
end
41+
42+
query_job.perform_later
43+
drain
44+
45+
transaction = sentry_events.find { |e| e.is_a?(Sentry::TransactionEvent) }
46+
expect(transaction).not_to be_nil
47+
48+
db_span = transaction.spans.find { |s| s[:op] == "db.sql.active_record" }
49+
expect(db_span).not_to be_nil
50+
end
51+
3552
it "marks the failing transaction internal_error and links the error event by trace_id" do
3653
expect do
3754
failing_job.perform_later

0 commit comments

Comments
 (0)