File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,13 @@ def backend
27
27
end
28
28
29
29
def valid?
30
- if mode . blank?
30
+ return false if mode . blank?
31
+
32
+ unless valid_backend?
33
+ AppProfiler . logger . info ( "[AppProfiler] unsupported backend='#{ backend } '" )
31
34
return false
32
35
end
33
36
34
- return false if backend != AppProfiler ::Backend ::StackprofBackend . name && !AppProfiler . vernier_supported?
35
-
36
37
if AppProfiler . vernier_supported? && backend == AppProfiler ::Backend ::VernierBackend . name &&
37
38
!AppProfiler ::Backend ::VernierBackend ::AVAILABLE_MODES . include? ( mode . to_sym )
38
39
AppProfiler . logger . info ( "[AppProfiler] unsupported profiling mode=#{ mode } for backend #{ backend } " )
@@ -50,6 +51,12 @@ def valid?
50
51
true
51
52
end
52
53
54
+ def valid_backend?
55
+ return true if AppProfiler ::Backend ::StackprofBackend . name == backend
56
+
57
+ AppProfiler . vernier_supported? && AppProfiler ::Backend ::VernierBackend . name == backend
58
+ end
59
+
53
60
def to_h
54
61
{
55
62
mode : mode . to_sym ,
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ class RequestParametersTest < TestCase
29
29
end
30
30
end
31
31
32
+ test "#valid? returns false when backend is not supported" do
33
+ AppProfiler . logger . expects ( :info ) . with { |value | value =~ /unsupported backend='not-a-real-backend'/ }
34
+ params = request_params ( headers : { AppProfiler . request_profile_header => "mode=cpu;backend=not-a-real-backend" } )
35
+
36
+ assert_not_predicate ( params , :valid? )
37
+ end
38
+
32
39
test "#context is AppProfiler.context by default" do
33
40
with_context ( "test-context" ) do
34
41
AppProfiler . logger . expects ( :info ) . never
You can’t perform that action at this time.
0 commit comments