Skip to content

Sentry::Scope#set_transaction_name leaks memory #2257

Closed

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions