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

Pause the transaction #2

Open
wants to merge 3 commits into
base: main
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
5 changes: 4 additions & 1 deletion lib/appsignal/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ def error?

# @api private
def complete
discard! if !error? && (rand > SAMPLING_RATE)
if !error? && (rand > SAMPLING_RATE)
pause!
discard!
end

if discarded?
Appsignal.internal_logger.debug "Skipping transaction '#{transaction_id}' " \
Expand Down
2 changes: 1 addition & 1 deletion lib/appsignal/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Appsignal
VERSION = "4.2.0"
VERSION = "4.2.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we not keep this in sync with the upstream? the version is anyways not relevant, since we're installing the gem from github

end
5 changes: 5 additions & 0 deletions spec/lib/appsignal/transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
transaction.add_tags(:foo => "bar")
transaction.complete
expect(transaction).to be_completed
expect(transaction).not_to be_paused
expect(transaction).not_to be_discarded
end
end
Expand All @@ -194,6 +195,7 @@
transaction.add_tags(:foo => "bar")
transaction.complete
expect(transaction).not_to be_completed
expect(transaction).to be_paused
expect(transaction).to be_discarded
end

Expand All @@ -206,6 +208,7 @@
transaction.add_tags(:foo => "bar")
transaction.complete
expect(transaction).to be_completed
expect(transaction).not_to be_paused
expect(transaction).not_to be_discarded
end
end
Expand All @@ -225,6 +228,7 @@
transaction.add_tags(:foo => "bar")
transaction.complete
expect(transaction).to be_completed
expect(transaction).not_to be_paused
expect(transaction).not_to be_discarded
end
end
Expand All @@ -242,6 +246,7 @@
transaction.add_tags(:foo => "bar")
transaction.complete
expect(transaction).not_to be_completed
expect(transaction).to be_paused
expect(transaction).to be_discarded
end
end
Expand Down