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

Fix Padrino instrumentation causing boot loop #1143

Merged
merged 1 commit into from
Jul 4, 2024
Merged
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
7 changes: 7 additions & 0 deletions .changesets/padrino-boot-loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
type: fix
---

Fix issue with AppSignal getting stuck in a boot loop when loading the Padrino integration with: `require "appsignal/integrations/padrino"`
This could happen in nested applications, like a Padrino app in a Rails app. AppSignal will now use the first config AppSignal starts with.
8 changes: 5 additions & 3 deletions lib/appsignal/integrations/padrino.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ def self.init
Padrino.before_load do
Appsignal.internal_logger.debug("Loading Padrino (#{Padrino::VERSION}) integration")

root = Padrino.mounted_root
Appsignal.config = Appsignal::Config.new(root, Padrino.env)
Appsignal.start
unless Appsignal.active?
root = Padrino.mounted_root
Appsignal.config = Appsignal::Config.new(root, Padrino.env)
Appsignal.start
end

next unless Appsignal.active?

Expand Down
31 changes: 31 additions & 0 deletions spec/lib/appsignal/integrations/padrino_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@ def uninstall_padrino_integration
end
end

context "when already active" do
before { allow(Appsignal).to receive(:active?).and_return(true) }

it "does not start AppSignal again" do
expect(Appsignal::Config).to_not receive(:new)
expect(Appsignal).to_not receive(:start)

Appsignal::Integrations::PadrinoPlugin.init
callbacks[:before_load].call
end

it "adds the instrumentation middleware to Sinatra::Base" do
Appsignal::Integrations::PadrinoPlugin.init
callbacks[:before_load].call

middlewares = Padrino.middleware
expect(middlewares).to include(
[Rack::Events, [[instance_of(Appsignal::Rack::EventHandler)]], nil]
)
expect(middlewares).to include(
[
Appsignal::Rack::SinatraBaseInstrumentation,
[
:instrument_span_name => "process_action.padrino"
],
nil
]
)
end
end

context "with active config" do
before do
ENV["APPSIGNAL_APP_NAME"] = "My Padrino app name"
Expand Down
Loading