Commit 1562bac7 authored by Sean McGivern's avatar Sean McGivern

Reduce memory consumption when an API exception goes to Sentry

When Sentry gets Rack context, it can grab information that is very
large (like Grape routing information) from the Rack environment. It can
waste a lot of time and memory processing that information, only to then
... not send it to Sentry as it's not a standard key.

https://github.com/getsentry/sentry-ruby/pull/1197 describes this
perfectly, but as we're not on the latest version,
https://github.com/getsentry/sentry-ruby/pull/1198 is the PR that we're
pulling in to fix this issue.

To test this locally:

1. Create a project.
2. Move or delete its on-disk repo.
3. Configure Sentry.
4. Run `curl http://$host/api/v4/projects/$id/repository/branches/main`.
5. Check the `mem_bytes` field in `api_json.log`.

This change takes several hundred megabytes from that value in my local
environment.

Changelog: performance
parent 5c0431b1
......@@ -306,7 +306,7 @@ gem 'gitlab-license', '~> 1.5'
gem 'rack-attack', '~> 6.3.0'
# Sentry integration
gem 'sentry-raven', '~> 3.0'
gem 'sentry-raven', '~> 3.1'
# PostgreSQL query parsing
gem 'pg_query', '~> 2.0.3'
......
......@@ -1167,7 +1167,7 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sentry-raven (3.0.4)
sentry-raven (3.1.2)
faraday (>= 1.0)
settingslogic (2.0.9)
sexp_processor (4.15.1)
......@@ -1599,7 +1599,7 @@ DEPENDENCIES
sassc-rails (~> 2.1.0)
seed-fu (~> 2.3.7)
selenium-webdriver (~> 3.142)
sentry-raven (~> 3.0)
sentry-raven (~> 3.1)
settingslogic (~> 2.0.9)
shoulda-matchers (~> 4.0.1)
sidekiq (~> 5.2.7)
......
......@@ -4,7 +4,15 @@ require 'spec_helper'
RSpec.describe Gitlab::ErrorTracking::Processor::ContextPayloadProcessor do
describe '.call' do
let(:event) { Raven::Event.new(payload) }
let(:required_options) do
{
configuration: Raven.configuration,
context: Raven.context,
breadcrumbs: Raven.breadcrumbs
}
end
let(:event) { Raven::Event.new(required_options.merge(payload)) }
let(:result_hash) { described_class.call(event).to_hash }
before do
......
......@@ -4,7 +4,15 @@ require 'spec_helper'
RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
describe '.call' do
let(:event) { Raven::Event.from_exception(exception, data) }
let(:required_options) do
{
configuration: Raven.configuration,
context: Raven.context,
breadcrumbs: Raven.breadcrumbs
}
end
let(:event) { Raven::Event.from_exception(exception, required_options.merge(data)) }
let(:result_hash) { described_class.call(event).to_hash }
context 'when there is no GRPC exception' do
......
......@@ -95,7 +95,15 @@ RSpec.describe Gitlab::ErrorTracking::Processor::SidekiqProcessor do
end
describe '.call' do
let(:event) { Raven::Event.new(wrapped_value) }
let(:required_options) do
{
configuration: Raven.configuration,
context: Raven.context,
breadcrumbs: Raven.breadcrumbs
}
end
let(:event) { Raven::Event.new(required_options.merge(wrapped_value)) }
let(:result_hash) { described_class.call(event).to_hash }
context 'when there is Sidekiq data' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment