-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup active storage subscriber tests
- Loading branch information
Showing
6 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
sentry-rails/spec/sentry/rails/tracing/active_storage_subscriber_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Sentry::Rails::Tracing::ActiveStorageSubscriber, :subscriber, type: :request do | ||
let(:transport) do | ||
Sentry.get_current_client.transport | ||
end | ||
|
||
context "when transaction is sampled" do | ||
before do | ||
make_basic_app do |config| | ||
config.traces_sample_rate = 1.0 | ||
config.rails.tracing_subscribers = [described_class] | ||
end | ||
end | ||
|
||
it "records the upload event" do | ||
p = Post.create! | ||
get "/posts/#{p.id}/attach" | ||
|
||
expect(response).to have_http_status(:ok) | ||
expect(transport.events.count).to eq(1) | ||
|
||
transaction = transport.events.first.to_hash | ||
expect(transaction[:type]).to eq("transaction") | ||
expect(transaction[:spans].count).to eq(1) | ||
|
||
span = transaction[:spans][0] | ||
expect(span[:op]).to eq("service_upload.active_storage") | ||
expect(span[:description]).to eq("Disk") | ||
expect(span.dig(:data, :key)).to eq(p.cover.key) | ||
expect(span[:trace_id]).to eq(transaction.dig(:contexts, :trace, :trace_id)) | ||
end | ||
end | ||
|
||
context "when transaction is not sampled" do | ||
before do | ||
make_basic_app | ||
end | ||
|
||
it "doesn't record spans" do | ||
p = Post.create! | ||
get "/posts/#{p.id}/attach" | ||
|
||
expect(response).to have_http_status(:ok) | ||
|
||
expect(transport.events.count).to eq(0) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
default: &default | ||
adapter: sqlite3 | ||
|
||
test: | ||
<<: *default | ||
database: db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test: | ||
service: Disk | ||
root: <%= Rails.root.join("tmp/storage") %> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.