
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
A Middleware and CLI for fetching and interacting with StackProf dumps.
stackprof-remote consists of a middleware for easy creation and retrieval of StackProf sampling profiler dumps from a remote machine, and a wrapper around pry (stackprof-cli) to create an interactive session for navigating dump files.
Currently, this is aimed at Rails apps running with unicorn, but there are options that should make it usable with any Rack app. In the future, I'd like to see it work with Resque and non-rack applications, too.
StackProf is amazing (BIG UPS TO @TMM1) but is not very operator friendly when it comes to collecting data about a current process. I was inspired by the go tool pprof
process to make something that could wrap StackProf in an interface that should be as easy as including a middleware and pointing a bin at it to fetch and navigate a dump.
1 - Add the Middleware to your app.
# rails 2.3 style
require 'stackprof/remote/middleware'
# Should we enable stackprof-remote for this request.
# enabled can be a boolean or a proc that takes the Rack env hash
enabled = proc do |env|
env['HOST_INFO'] =~ /private-hostname/ || Rails.env.development?
end
# Register the middleware
ActionController::Dispatcher.middleware.use StackProf::Remote::Middleware, enabled: enabled, logger: Rails.logger
2 - Run/restart your app. 3 - Attach to your application.
$ stackprof-remote localhost
=== StackProf on localhost ===
Starting
[localhost] StackProf Started
Waiting for 30 seconds
[localhost] Results: 3023kb
Saved results to /home/paperless/.sp/sp-localhost-1402684964.dump
>>> sp-localhost-1402684964.dump loaded
stackprof> top 5
==================================
Mode: cpu(1000)
Samples: 5045 (3.28% miss rate)
GC: 355 (7.04%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
736 (14.6%) 707 (14.0%) ActiveSupport::LogSubscriber#start
379 (7.5%) 379 (7.5%) block in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#execute
5248 (104.0%) 168 (3.3%) Benchmark#realtime
282 (5.6%) 117 (2.3%) ActiveSupport::LogSubscriber#finish
88 (1.7%) 88 (1.7%) block (2 levels) in Sass::Importers::Filesystem#find_real_file
At the end of stackprof-remote
it actually just enters a separate process stackprof-cli
. This is a wrapper around pry that loads the dump file in an interactive session. It gives you a number of methods to interact with the dump:
You can use stackprof-cli
on its own by calling stackprof-cli [dump-name]
enabled
on the Middleware to lock this down in production environments.rbtrace
to execute the stackprof methods against the pool of unicorns running. If you're running something other than unicorn
or you mess with the procline, you'll need to set the :pid_finder
option.method
view you need to execute stackprof-cli
in the same directory structure that your unicorn runs in. This doesn't necessarily mean the same server - we use remote dumps and inspect them in our local Vagrant environments that have the same directory structure.Only works on MRI Ruby 2.1 (Upgrade already!). Its only been tested against Ruby 2.1.2 running on Linux (Centos 6.4).
Copyright (c) 2014 Aaron Quint. See LICENSE.txt for further details.
FAQs
Unknown package
We found that stackprof-remote demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.