diff --git a/lib/app_profiler/middleware.rb b/lib/app_profiler/middleware.rb index 63947e1d..0b70fe3c 100644 --- a/lib/app_profiler/middleware.rb +++ b/lib/app_profiler/middleware.rb @@ -31,7 +31,7 @@ def profile(env, params) return yield unless before_profile(env, params_hash) - profile = AppProfiler.run(params_hash, backend: params.backend) do + profile = AppProfiler.run(**params_hash) do response = yield end diff --git a/lib/app_profiler/parameters.rb b/lib/app_profiler/parameters.rb index 42c197bc..1bdc6696 100644 --- a/lib/app_profiler/parameters.rb +++ b/lib/app_profiler/parameters.rb @@ -15,7 +15,7 @@ def initialize(mode: :wall, interval: nil, ignore_gc: false, autoredirect: false @interval = [interval&.to_i || DEFAULT_INTERVALS.fetch(@mode.to_s), MIN_INTERVALS.fetch(@mode.to_s)].max @ignore_gc = !!ignore_gc @autoredirect = autoredirect - @backend = backend + @backend = backend || AppProfiler::Backend::StackprofBackend::NAME @metadata = { context: AppProfiler.context }.merge(metadata) @async = async end @@ -30,6 +30,7 @@ def to_h interval: @interval, ignore_gc: @ignore_gc, metadata: @metadata, + backend: @backend, } end end diff --git a/lib/app_profiler/request_parameters.rb b/lib/app_profiler/request_parameters.rb index c3509d6e..35468194 100644 --- a/lib/app_profiler/request_parameters.rb +++ b/lib/app_profiler/request_parameters.rb @@ -51,6 +51,7 @@ def to_h mode: mode.to_sym, interval: interval.to_i, ignore_gc: !!ignore_gc, + backend: backend, metadata: { id: request_id, context: context, diff --git a/test/app_profiler/request_parameters_test.rb b/test/app_profiler/request_parameters_test.rb index 32a9ea1f..17048353 100644 --- a/test/app_profiler/request_parameters_test.rb +++ b/test/app_profiler/request_parameters_test.rb @@ -58,7 +58,8 @@ class RequestParametersTest < TestCase }) assert_equal( - { mode: mode.to_sym, interval: interval.to_i, ignore_gc: true, metadata: { id: "123", context: "test" } }, + { mode: mode.to_sym, interval: interval.to_i, backend: :stackprof, ignore_gc: true, + metadata: { id: "123", context: "test" }, }, params.to_h ) assert_predicate(params, :valid?)