vagrant-timer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +9 -0
- data/README.md +72 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/vagrant/timer/version.rb +5 -0
- data/lib/vagrant/timer.rb +72 -0
- data/vagrant-timer.gemspec +29 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f26c5ad314f09f36ad9a022a7982720e2bae87c1
|
4
|
+
data.tar.gz: ed75e493ca05c451310c95d652cf2f03151e2092
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6db17b40c14b0123eccfb270a1121dc1c42ddeb7625e32b9360f4fd0056a3b1a9a2240f1714ab5e6d0068fed0792edb239fb6024b29350d7395d4b83a9d173e5
|
7
|
+
data.tar.gz: 5ee00c2074273b55edef6f943655e54b9027c57d68a2e6099f9d0130b790e4683df18b058ed66c10e7afe2545eaa504137a5a580aebb35eb670125b0335326e5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# VagrantTimer
|
2
|
+
|
3
|
+
The `vagrant-timer` vagrant plugin allows you to capture diagnostic logging
|
4
|
+
about the duration that various vagrant actions take, and save them to a file
|
5
|
+
for later analysis.
|
6
|
+
|
7
|
+
Each line of the log file is a JSON object with the following keys:
|
8
|
+
|
9
|
+
<dl>
|
10
|
+
<dt>box</dt>
|
11
|
+
<dd>The name of the base vagrant box being run</dd>
|
12
|
+
|
13
|
+
<dt>action_name</dt>
|
14
|
+
<dd>
|
15
|
+
The hook being executed. Documented
|
16
|
+
<a href="https://www.vagrantup.com/docs/plugins/action-hooks.html">by Vagrant</a>
|
17
|
+
</dd>
|
18
|
+
|
19
|
+
<dt>initialized_at</dt>
|
20
|
+
<dd>ISO 8601 timestame recording the time that the hook was initialized</dd>
|
21
|
+
|
22
|
+
<dt>started_at</dt>
|
23
|
+
<dd>ISO 8601 timestame recording the time that the hook was called</dd>
|
24
|
+
|
25
|
+
<dt>ended_at</dt>
|
26
|
+
<dd>ISO 8601 timestame recording the time that the hook call ended</dd>
|
27
|
+
|
28
|
+
<dt>init_duration</dt>
|
29
|
+
<dd>Duration in seconds from the time the hook was initialized to when it was called</dd>
|
30
|
+
|
31
|
+
<dt>call_duration</dt>
|
32
|
+
<dd>Duration in seconds from the start of the hook call to the end of the hook call</dd>
|
33
|
+
</dl>
|
34
|
+
|
35
|
+
## Installation
|
36
|
+
|
37
|
+
Run `vagrant plugin install vagrant-timer`
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
Set the environment variable `VAGRANT_TIMER_LOG` to a filename to record the
|
42
|
+
durations of all executed vagrant actions. The log messages will be appended
|
43
|
+
to the specified file. If the variable is unset, no messages will be logged.
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can
|
48
|
+
also run `bin/console` for an interactive prompt that will allow you to
|
49
|
+
experiment.
|
50
|
+
|
51
|
+
To run this plugin locally, use `bundle exec vagrant <some command>`. This will use the
|
52
|
+
local `Vagrantfile` in the current repository. To install the plugin in your
|
53
|
+
local vagrant environment without publishing to [rubygems.org](https://rubygems.org),
|
54
|
+
do the following:
|
55
|
+
|
56
|
+
``` sh
|
57
|
+
$ rake build
|
58
|
+
$ bundle cache --all
|
59
|
+
$ cp pkg/*.gem vendor/cache
|
60
|
+
$ mv vendor/cache vendor/gems
|
61
|
+
$ gem generate_index -d vendor
|
62
|
+
$ vagrant plugin install vagrant-timer --plugin-source=file://$(pwd)/vendor
|
63
|
+
```
|
64
|
+
|
65
|
+
To release a new version, update the version number in `version.rb`, and then
|
66
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
67
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/edx/vagrant-timer.
|
72
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "vagrant/timer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require "vagrant/timer/version"
|
2
|
+
|
3
|
+
require "vagrant"
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module Timer
|
7
|
+
class Plugin < Vagrant.plugin("2")
|
8
|
+
name "vagrant-timer"
|
9
|
+
description <<-DESC
|
10
|
+
A plugin to capture timing information from a vagrant run.
|
11
|
+
Set the environment variable VAGRANT_TIMER_LOG to the file to
|
12
|
+
log timing data to.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
action_hook("timer") do |hook|
|
16
|
+
hook.prepend(Middleware)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Middleware
|
21
|
+
@@previous_action_name = nil
|
22
|
+
|
23
|
+
def initialize(app, env)
|
24
|
+
@init_time = Time.now.utc
|
25
|
+
|
26
|
+
@app = app
|
27
|
+
end
|
28
|
+
|
29
|
+
def call(env)
|
30
|
+
@start_call = Time.now.utc
|
31
|
+
@app.call(env)
|
32
|
+
@end_call = Time.now.utc
|
33
|
+
|
34
|
+
env_obj = env[:env]
|
35
|
+
vagrantfile = env_obj && env_obj.vagrantfile
|
36
|
+
config = vagrantfile && vagrantfile.config
|
37
|
+
vm = config && config.vm
|
38
|
+
box = vm && vm.box
|
39
|
+
|
40
|
+
event = {
|
41
|
+
:ruby_version => RUBY_VERSION,
|
42
|
+
:platform => RUBY_PLATFORM,
|
43
|
+
:vagrant_version => Vagrant::VERSION,
|
44
|
+
:box => box,
|
45
|
+
:action_name => env[:action_name],
|
46
|
+
:initialized_at => @init_time,
|
47
|
+
:started_at => @start_call,
|
48
|
+
:ended_at => @end_call,
|
49
|
+
:init_duration => @start_call - @init_time,
|
50
|
+
:call_duration => @end_call - @start_call,
|
51
|
+
}
|
52
|
+
|
53
|
+
if !@@previous_action_name.nil?
|
54
|
+
event[:previous_action_name] = @@previous_action_name
|
55
|
+
event[:since_previous_action] = @init_time - @@previous_action_end
|
56
|
+
end
|
57
|
+
|
58
|
+
if !ENV['VAGRANT_TIMER_LOG'].nil?
|
59
|
+
begin
|
60
|
+
File.open(ENV['VAGRANT_TIMER_LOG'], 'a') do |file|
|
61
|
+
file.write(event.to_json + "\n")
|
62
|
+
end
|
63
|
+
rescue SystemCallError => err
|
64
|
+
puts "Unable to log event to #{ENV['VAGRANT_TIMER_LOG']}: #{err}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@@previous_action_name = env[:action_name]
|
68
|
+
@@previous_action_end = @end_call
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant/timer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-timer"
|
8
|
+
spec.version = Vagrant::Timer::VERSION
|
9
|
+
spec.authors = ["Calen Pennington"]
|
10
|
+
spec.email = ["cale@edx.org"]
|
11
|
+
|
12
|
+
spec.summary = "Vagrant plugin to dump timing information about commands"
|
13
|
+
spec.homepage = "https://github.com/edx/vagrant-timer"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-timer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Calen Pennington
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- cale@edx.org
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- bin/console
|
39
|
+
- bin/setup
|
40
|
+
- lib/vagrant/timer.rb
|
41
|
+
- lib/vagrant/timer/version.rb
|
42
|
+
- vagrant-timer.gemspec
|
43
|
+
homepage: https://github.com/edx/vagrant-timer
|
44
|
+
licenses: []
|
45
|
+
metadata:
|
46
|
+
allowed_push_host: https://rubygems.org
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.5.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Vagrant plugin to dump timing information about commands
|
67
|
+
test_files: []
|