cloudpi-appmetric 0.0.6 → 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.
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.3)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.7.3)
11
+ rake (0.9.2.2)
12
+ rcov (1.0.0)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+ shoulda (3.0.1)
16
+ shoulda-context (~> 1.0.0)
17
+ shoulda-matchers (~> 1.0.0)
18
+ shoulda-context (1.0.0)
19
+ shoulda-matchers (1.0.0)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ bundler (~> 1.0.0)
26
+ jeweler (~> 1.8.3)
27
+ json
28
+ rcov
29
+ rdoc (~> 3.12)
30
+ shoulda
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.1.0
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cloudpi-appmetric}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Junsang Yang}]
12
+ s.date = %q{2012-06-10}
13
+ s.description = %q{CloudPI PaaS - Application Metric Client for ruby}
14
+ s.email = %q{junsang.yang@samsung.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "cloudpi-appmetric.gemspec",
28
+ "lib/cloudpi-appmetric.rb",
29
+ "test/helper.rb",
30
+ "test/test_cloudpi-appmetric.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/zuns00@gmail.com/cloudpi-appmetric}
33
+ s.licenses = [%q{MIT}]
34
+ s.require_paths = [%q{lib}]
35
+ s.rubygems_version = %q{1.8.6}
36
+ s.summary = %q{CloudPI PaaS - Application Metric Client for ruby}
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
43
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
46
+ s.add_development_dependency(%q<rcov>, [">= 0"])
47
+ s.add_development_dependency(%q<json>, [">= 0"])
48
+ else
49
+ s.add_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
53
+ s.add_dependency(%q<rcov>, [">= 0"])
54
+ s.add_dependency(%q<json>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<shoulda>, [">= 0"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ s.add_dependency(%q<json>, [">= 0"])
63
+ end
64
+ end
65
+
@@ -67,13 +67,15 @@ class AppMetric
67
67
  @app_ip = ENV["VCAP_APP_HOST"] || '127.0.0.1'
68
68
  @app_port = ENV["VCAP_APP_PORT"] || 9999
69
69
  env_vcap_application = JSON.parse(ENV["VCAP_APPLICATION"])
70
+ app_id = env_vcap_application["app_id"] if env_vcap_application
70
71
  instance_id = env_vcap_application["instance_id"] if env_vcap_application
71
- @app_id = instance_id || 'NO_INSTANCE_ID'
72
+ @app_id = app_id || ''
73
+ @instance_id = instance_id || ''
72
74
  @bridge_ip = bridge_ip
73
75
  @bridge_port = bridge_port
74
76
  @metric_policy = JSON.parse(metric_policy)
75
77
  @queue = CircularQueue.new(4096)
76
-
78
+
77
79
  connect
78
80
  thread_loop
79
81
  end
@@ -94,7 +96,11 @@ class AppMetric
94
96
  end
95
97
 
96
98
  def metric_key
97
- "#{@app_ip}:#{@app_port}:#{@app_id}"
99
+ # "IP-ADDRESS:PORT:APP-ID:INSTANCE-ID" or
100
+ # "IP-ADDRESS:PORT:APP-INSTANCE-ID".
101
+
102
+ # "#{@app_ip}:#{@app_port}:#{@instance_id}"
103
+ "#{@app_ip}:#{@app_port}:#{@app_id}:#{@instance_id}"
98
104
  end
99
105
 
100
106
  def set_metric_policy(metric_policy)
@@ -130,11 +136,11 @@ class AppMetric
130
136
  thread = Thread.new do
131
137
  loop do
132
138
  while !@queue.is_empty do
133
- puts "not empty queue: #{@queue.cursor}"
139
+ # puts "not empty queue: #{@queue.cursor}"
134
140
  @message = @queue.first
135
141
  begin
136
142
  @conn.write("#{@message}\0")
137
- puts "send msg: #{@message}"
143
+ # puts "send msg: #{@message}"
138
144
  @queue.pop
139
145
  rescue
140
146
  # retry to connect
@@ -146,15 +152,17 @@ class AppMetric
146
152
  end # loop
147
153
  end # thread
148
154
 
149
- heartbeat_thread = Thread.new do
150
- loop do
151
- send_heartbeat
152
- sleep(10.0)
153
- end # loop
154
- end # thread
155
+ # no need to send heartbeat, dea metric will do that..
156
+
157
+ # heartbeat_thread = Thread.new do
158
+ # loop do
159
+ # send_heartbeat
160
+ # sleep(10.0)
161
+ # end # loop
162
+ # end # thread
155
163
 
156
164
  set_trap(thread)
157
- set_trap(heartbeat_thread)
165
+ # set_trap(heartbeat_thread)
158
166
  end
159
167
 
160
168
  def set_trap(thread)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudpi-appmetric
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 6
10
- version: 0.0.6
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Junsang Yang
@@ -118,10 +118,12 @@ extra_rdoc_files:
118
118
  files:
119
119
  - .document
120
120
  - Gemfile
121
+ - Gemfile.lock
121
122
  - LICENSE.txt
122
123
  - README.rdoc
123
124
  - Rakefile
124
125
  - VERSION
126
+ - cloudpi-appmetric.gemspec
125
127
  - lib/cloudpi-appmetric.rb
126
128
  - test/helper.rb
127
129
  - test/test_cloudpi-appmetric.rb