instrumental 0.1.5 → 0.1.6

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
data/instrumental.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{instrumental}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Douglas F Shearer"]
12
- s.date = %q{2011-06-09}
12
+ s.date = %q{2011-06-10}
13
13
  s.description = %q{Rails instrumentation and client for imperialapp.com}
14
14
  s.email = %q{support@imperialapp.com}
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/instrumental/configuration.rb",
31
31
  "lib/instrumental/intervalometer.rb",
32
32
  "lib/tasks/install.rake",
33
+ "lib/tasks/milestone.rake",
33
34
  "lib/tasks/templates/instrumental.rb.erb",
34
35
  "spec/instrumental/agent_spec.rb",
35
36
  "spec/instrumental/configuration_spec.rb",
@@ -25,6 +25,10 @@ module Instrumental
25
25
  end
26
26
  end
27
27
 
28
+ def milestone(name = Time.now.utc.to_s)
29
+ post_response("#{ config.path }/milestone", { :name => name })
30
+ end
31
+
28
32
  def setup_and_run
29
33
  @intervalometer = Intervalometer.new(config.report_interval)
30
34
 
@@ -70,20 +74,14 @@ module Instrumental
70
74
 
71
75
  def send_report(type, name, value)
72
76
  if type == :measure
73
- attributes = { :values => value }
77
+ params = { :values => value }
74
78
  else
75
- attributes = { :value => value }
79
+ params = { :value => value }
76
80
  end
77
81
 
78
- attributes[:name] = URI.escape("#{ config.name_prefix }#{ name }")
79
- attributes[:api_key] = config.api_key
80
-
81
- # attributes_string = attributes.to_a.map{ |a| a.join('=') }.join('&')
82
-
83
82
  path = "#{ config.path }#{ type }"
84
- # config.logger.debug("Calling #{ path }")
85
83
 
86
- response = post_response(path, attributes)
84
+ response = post_response(path, params)
87
85
 
88
86
  unless response.is_a?(Net::HTTPSuccess)
89
87
  config.logger.error "[Instrumental] Unexpected response from server (#{ response.code }): #{ response.message }"
@@ -91,6 +89,9 @@ module Instrumental
91
89
  end
92
90
 
93
91
  def post_response(path, params)
92
+ params[:api_key] = config.api_key
93
+ params[:name] = URI.escape("#{ config.name_prefix }#{ params[:name] }")
94
+
94
95
  req = Net::HTTP::Post.new(path)
95
96
  req.set_form_data(params)
96
97
  Net::HTTP.new(config.host, config.port).start { |h| h.request(req) }
data/lib/instrumental.rb CHANGED
@@ -49,4 +49,8 @@ module Instrumental
49
49
  self.measure(name, (Time.now - start_time) * 1000) # milliseconds
50
50
  end
51
51
 
52
+ def self.milestone(name)
53
+ Agent.instance.milestone(name)
54
+ end
55
+
52
56
  end
@@ -0,0 +1,8 @@
1
+ namespace :instrumental do
2
+
3
+ desc "Adds a milestone marker to the Imperial project"
4
+ task :milestone => :environment do
5
+ Instrumental.milestone(ENV['name'])
6
+ end
7
+
8
+ end
@@ -47,4 +47,12 @@ describe 'public instrument methods' do
47
47
  end
48
48
  end
49
49
 
50
+ describe "measure" do
51
+ it "should send the passed value" do
52
+ @mock_agent_instance.should_receive(:milestone).with('my name')
53
+
54
+ Instrumental.milestone('my name')
55
+ end
56
+ end
57
+
50
58
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instrumental
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Douglas F Shearer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-09 00:00:00 +01:00
18
+ date: 2011-06-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -83,6 +83,7 @@ files:
83
83
  - lib/instrumental/configuration.rb
84
84
  - lib/instrumental/intervalometer.rb
85
85
  - lib/tasks/install.rake
86
+ - lib/tasks/milestone.rake
86
87
  - lib/tasks/templates/instrumental.rb.erb
87
88
  - spec/instrumental/agent_spec.rb
88
89
  - spec/instrumental/configuration_spec.rb