VagrantTimer

The vagrant-timer vagrant plugin allows you to capture diagnostic logging about the duration that various vagrant actions take, and save them to a file for later analysis.

Each line of the log file is a JSON object with the following keys:

box
The name of the base vagrant box being run
action_name
The hook being executed. Documented by Vagrant
initialized_at
ISO 8601 timestame recording the time that the hook was initialized
started_at
ISO 8601 timestame recording the time that the hook was called
ended_at
ISO 8601 timestame recording the time that the hook call ended
init_duration
Duration in seconds from the time the hook was initialized to when it was called
call_duration
Duration in seconds from the start of the hook call to the end of the hook call

Installation

Run vagrant plugin install vagrant-timer

Usage

Set the environment variable VAGRANT_TIMER_LOG to a filename to record the durations of all executed vagrant actions. The log messages will be appended to the specified file. If the variable is unset, no messages will be logged.

The log file name may include formatting variables understood by strftime. These will be interpolated with the start time of the event. For example, if VAGRANT_TIMER_LOG = .vagrant-logs/%Y-%m-%d.log, then an event that happens on July 21st, 2016 will end up in the log file .vagrant-logs/2016-07-21.log.

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To run this plugin locally, use bundle exec vagrant <some command>. This will use the local Vagrantfile in the current repository. To install the plugin in your local vagrant environment without publishing to rubygems.org, do the following:

$ rake build
$ bundle cache --all
$ cp pkg/*.gem vendor/cache
$ mv vendor/cache vendor/gems
$ gem generate_index -d vendor
$ vagrant plugin install vagrant-timer --plugin-source=file://$(pwd)/vendor

To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/edx/vagrant-timer.