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

Validate the backend in params #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sam-Killgallon
Copy link

@Sam-Killgallon Sam-Killgallon commented Oct 18, 2024

Explicitly handle the case when the backend provided by params is not supported by AppProfiler

Skip profiling if the backend is not supported
@Sam-Killgallon Sam-Killgallon force-pushed the validate-backend-params branch from 4114413 to d402d3a Compare October 18, 2024 14:35
@Sam-Killgallon Sam-Killgallon marked this pull request as ready for review October 18, 2024 14:38
@@ -50,6 +51,12 @@ def valid?
true
end

def valid_backend?
return true if AppProfiler::Backend::StackprofBackend.name == backend
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it achieves the same outcome and it is probably a matter of personal preference - but I would rather get rid of AppProfiler::Backend::StackprofBackend.name == backend and have something which checks if backend is one of the two. We can define a constant AVAILABLE_BACKENDS

@@ -29,6 +29,13 @@ class RequestParametersTest < TestCase
end
end

test "#valid? returns false when backend is not supported" do
AppProfiler.logger.expects(:info).with { |value| value =~ /unsupported backend='not-a-real-backend'/ }
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we do not need check the logs and valid? is sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants