minstrel 0.2.20101115033015 → 0.2.20101115170047
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +18 -0
- data/bin/minstrel +18 -1
- data/lib/minstrel.rb +1 -1
- metadata +3 -3
data/README.textile
CHANGED
@@ -51,6 +51,22 @@ exit String#reverse([])
|
|
51
51
|
dlrow olleH
|
52
52
|
</pre>
|
53
53
|
|
54
|
+
h4. Example: Tracing puppet storeconfigs (aka Tracing ActiveRecord queries)
|
55
|
+
|
56
|
+
ActiveRecord has a base class for most things query-related. Let's trace that:
|
57
|
+
|
58
|
+
<pre>
|
59
|
+
% sudo env RUBY_INSTRUMENT=ActiveRecord::ConnectionAdapters::DatabaseStatements minstrel puppet ...
|
60
|
+
enter ActiveRecord::ConnectionAdapters::DatabaseStatements#select_all(["SELECT DISTINCT
|
61
|
+
`hosts`.id FROM `hosts` LEFT OUTER JOIN `fact_values` ON `fact_values`.`host_id` = `h
|
62
|
+
osts`.`id` LEFT OUTER JOIN `fact_names` ON `fact_names`.`id` = `fact_values`.`fact_name_id`
|
63
|
+
...
|
64
|
+
enter ActiveRecord::ConnectionAdapters::DatabaseStatements#select_all(["SELECT `hosts`.`id` AS t0_r0, `hosts`.`name` AS t0_r1, `hosts`.`ip` AS t0_r2, `hosts`.`environment ...
|
65
|
+
</pre>
|
66
|
+
|
67
|
+
So easy :)
|
68
|
+
|
69
|
+
|
54
70
|
h3. From ruby
|
55
71
|
|
56
72
|
Boilerplate:
|
@@ -118,3 +134,5 @@ Wrap of TCPSocket successful
|
|
118
134
|
|
119
135
|
Minstrel will wrap 'require' and check for classes you want wrapped at each
|
120
136
|
require until it finds all the classes you asked to be wrapped.
|
137
|
+
|
138
|
+
|
data/bin/minstrel
CHANGED
@@ -5,4 +5,21 @@ require "minstrel"
|
|
5
5
|
|
6
6
|
$0 = ARGV[0]
|
7
7
|
ARGV.shift
|
8
|
-
|
8
|
+
begin
|
9
|
+
load $0
|
10
|
+
rescue LoadError => e
|
11
|
+
if File.basename($0) == $0 # if the file is just a name, not a path.
|
12
|
+
found = false
|
13
|
+
ENV["PATH"].split(":").each do |path|
|
14
|
+
file = "#{path}/#{$0}"
|
15
|
+
if File.exists?(file)
|
16
|
+
load file
|
17
|
+
found = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
raise e if !found
|
22
|
+
else
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
end
|
data/lib/minstrel.rb
CHANGED
@@ -47,8 +47,8 @@ module Minstrel; class Instrument
|
|
47
47
|
next if DONOTWRAP.include?(method.to_sym)
|
48
48
|
klass.class_eval do
|
49
49
|
orig_method = "#{method}_original(wrapped)".to_sym
|
50
|
-
alias_method orig_method, method.to_sym
|
51
50
|
method = method.to_sym
|
51
|
+
alias_method orig_method, method
|
52
52
|
#block.call(:wrap, klass, method)
|
53
53
|
define_method(method) do |*args, &argblock|
|
54
54
|
block.call(:enter, klass, method, *args)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minstrel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 40202230340073
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 20101115170047
|
10
|
+
version: 0.2.20101115170047
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordan Sissel
|