Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only expose ActiveStorage keys on span data if send_default_pii is on #2589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Add new sidekiq config `report_only_dead_jobs` ([#2581](https://github.com/getsentry/sentry-ruby/pull/2581))
- Add `max_nesting` of 10 to breadcrumbs data serialization ([#2583](https://github.com/getsentry/sentry-ruby/pull/2583))
- Only expose `active_storage` keys on span data if `send_default_pii` is on ([#2589](https://github.com/getsentry/sentry-ruby/pull/2589))

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def self.subscribe!
duration: duration
) do |span|
payload.each do |key, value|
span.set_data(key, value) unless key == START_TIMESTAMP_NAME
next if key == START_TIMESTAMP_NAME
next if key == :key && !Sentry.configuration.send_default_pii

span.set_data(key, value)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,34 @@
expect(span[:op]).to eq("file.service_upload.active_storage")
expect(span[:origin]).to eq("auto.file.rails")
expect(span[:description]).to eq("Disk")
expect(span.dig(:data, :key)).to eq(p.cover.key)
expect(span.dig(:data, :key)).to be_nil
expect(span[:trace_id]).to eq(request_transaction.dig(:contexts, :trace, :trace_id))
end

context "with send_default_pii = true" do
before do
make_basic_app do |config|
config.traces_sample_rate = 1.0
config.send_default_pii = true
config.rails.tracing_subscribers = [described_class]
end
end

it "records the :key in span.data" do
# make sure AnalyzeJob will be executed immediately
ActiveStorage::AnalyzeJob.queue_adapter.perform_enqueued_jobs = true

p = Post.create!
get "/posts/#{p.id}/attach"

request_transaction = transport.events.last.to_hash
expect(request_transaction[:type]).to eq("transaction")
expect(request_transaction[:spans].count).to eq(2)

span = request_transaction[:spans][1]
expect(span.dig(:data, :key)).to eq(p.cover.key)
end
end
end

context "when transaction is not sampled" do
Expand Down
Loading