Skip to content

Commit

Permalink
Add backend to params and request params hash
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehamel committed Mar 6, 2024
1 parent 7bb20b4 commit 54f659a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/app_profiler/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion lib/app_profiler/parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +30,7 @@ def to_h
interval: @interval,
ignore_gc: @ignore_gc,
metadata: @metadata,
backend: @backend,
}
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/app_profiler/request_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion test/app_profiler/request_parameters_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down

0 comments on commit 54f659a

Please sign in to comment.