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

Sentry::Scope#set_transaction_name leaks memory #2257

Open
c960657 opened this issue Mar 7, 2024 · 1 comment
Open

Sentry::Scope#set_transaction_name leaks memory #2257

c960657 opened this issue Mar 7, 2024 · 1 comment
Assignees

Comments

@c960657
Copy link
Contributor

c960657 commented Mar 7, 2024

Issue Description

The method name Sentry::Scope#set_transaction_name suggests that it is a simple setter, but in fact it appends the specified name to an array. AFAICT this array is never popped/truncated, so if #set_transaction_name is called e.g. in an event loop, the array will grow unlimited.

I know that Sentry.with_scope is often a better solution inside a loop, but this is not always a feasible solution, e.g. if exceptions are rescued outside the loop.

Reproduction Steps

while true do
  Sentry.configure_scope do |scope|
    scope.set_transaction_name('foo')
    p scope.transaction_names.size
  end
end

Expected Behavior

The transaction names should not accumulate.

Actual Behavior

An ever increasing number is output, proving that the Sentry::Scope#transaction_names array keeps growing. Eventually a NoMemoryError is raised.

Ruby Version

3.2.3

SDK Version

5.15.0

Integration and Its Version

No response

Sentry Config

No response

@sl0thentr0py
Copy link
Member

thx for the report, this whole transaction name stuff is a bit of mess at the moment. In general, there's no reason it needs to be an array, we just care about the last one anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants