![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Simple profiler for Rack applications (Sinatra, Ruby on Rails, or Grape for example). It helps providing an answer to common questions like:
ActiveRecord
?And more.
Rack::Profiler
uses the Active Support Instrumentation
API and
subscribes by default to the following hooks:
Rack::Profiler
also automatically subscribes to Grape's Active Support Instrumentation notifications
On top of this, you can also define your own events, by wrapping your code with
the Rack::Profiler.step
.
Rack::Profiler
is easy to integrate in any Rack application and it produces a
JSON response with the results. It also exposes a simple web dashboard to directly
issue HTTP requests to your application and see the results of the profiling.
Add this line to your application's Gemfile:
gem 'rack-profiler'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-profiler
In your config.ru
use the Rack::Profiler
middleware at the beginning of your
middleware stack:
require 'rack/profiler'
use Rack::Profiler
NOTE: you should not expose the profiler publicly in the production environment,
as it may contain sensitive information. Refer to the authorization section
on how to protect it.
You can add the Rack::Profiler
middleware at the beginning of your config.ru
like in the Rack/Sinatra installation or insert it in the middlewares stack configuration
in your config/environments/<env>.rb
files:
YourApp.configure do |config|
# ...
config.middleware.insert 0, Rack::Profiler
end
NOTE: you should not expose the profiler publicly in the production environment,
as it may contain sensitive information. Refer to the authorization section
for on to protect it.
You can configure Rack::Profiler
passing a block to use
(or
middleware.insert
in Rails configuration). In the block you can subscribe to
more notifications and change some defaults:
use Rack::Profiler do |profiler|
# Subscribe to email delivery in a Rails app
profiler.subscribe('deliver.action_mailer')
# You can also exclude lines that are not interesting from the backtrace
# For example, exclude gems from the backtrace:
profiler.filter_backtrace { |line| !line.include? '/gems/' }
end
You typically do not want to expose profiling publicly, as it may contain sensible information about your data and app. To protect your data, the easiest option is to only enable the profiler in the development environment:
if ENV['RACK_ENV'] == 'development'
require 'rack/profiler'
use Rack::Profiler
end
Sometimes though, you might want to run the profiler in the production environment, in order to get results in a real setting (including caching and optimizations). In this case, you can configure your custom authorization logic, which can rely on the Rack env:
use Rack::Profiler do |profiler|
profiler.authorize do |env|
# env is the Rack environment of the request. This block should return a
# truthy value when the request is allowed to be profiled, falsy otherwise.
env['rack-profiler-enabled'] == true
end
end
# ...then in your app:
before do
env['rack-profiler-enabled'] = true if current_user.admin?
end
By default Rack::Profiler
will subscribe to ActiveRecord
SQL queries,
ActionView
rendering events (templates and partials), ActionController
actions and to steps you define in your code with:
Rack::Profiler.step('your-step-name') do
# Do stuff. The profiler will tell you how long it took to perform this step
end
A graphical interface to profile your application pages/endpoints and display the results is automatically mounted at this route:
http://<your-app-url>/rack-profiler
Just select the HTTP verb, insert the relative path to your app and add some
optional parameters like POST/PUT data: Rack::Profiler
automatically send
the request to your app with the rack-profiler
param and display the
results in a nice graphical way.
If you want to access the results of the profiling as raw JSON data, you can just
add the rack-profiler
parameter (it can be null) to any HTTP request
to your app (GET, POST, PUT, PATCH, DELETE): Rack::Profiler
will execute the
request and return a JSON response containing the results along with the
original response.
http://<your-app-url>/<path>?rack-profiler
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that rack-profiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.