profit 0.1.4 → 0.1.5
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/lib/profit/client.rb +7 -5
- data/lib/profit/version.rb +1 -1
- data/spec/lib/client_spec.rb +16 -0
- metadata +3 -3
data/lib/profit/client.rb
CHANGED
@@ -28,14 +28,16 @@ module Profit
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def stop(metric_type)
|
31
|
-
now
|
32
|
-
metric
|
33
|
-
recorded_time =
|
34
|
-
|
35
|
-
|
31
|
+
now = Time.now
|
32
|
+
metric = @pending.delete key_for(metric_type)
|
33
|
+
recorded_time = now - metric[:start_time]
|
34
|
+
start_time = metric[:start_time].to_i
|
35
|
+
stop_file = caller[0][/(.+):(.+):/,1]
|
36
|
+
stop_line = caller[0][/(.+):(.+):/,2].to_i - 1
|
36
37
|
|
37
38
|
socket.send({ metric_type: metric_type,
|
38
39
|
recorded_time: recorded_time,
|
40
|
+
start_time: start_time,
|
39
41
|
start_file: metric[:start_file],
|
40
42
|
start_line: metric[:start_line],
|
41
43
|
stop_file: stop_file,
|
data/lib/profit/version.rb
CHANGED
data/spec/lib/client_spec.rb
CHANGED
@@ -26,6 +26,22 @@ describe Profit::Client do
|
|
26
26
|
expect(metric['recorded_time']).to be_within(0.1).of(1)
|
27
27
|
end
|
28
28
|
|
29
|
+
it "sends the unix time of when the measurement started" do
|
30
|
+
metrics = redis.lrange("profit:metric:some_foo_measurement", 0, -1)
|
31
|
+
expect(metrics).to be_empty
|
32
|
+
|
33
|
+
client.start("some_foo_measurement")
|
34
|
+
now = Time.now
|
35
|
+
sleep 1
|
36
|
+
client.stop("some_foo_measurement")
|
37
|
+
|
38
|
+
server_thread.join(0.1)
|
39
|
+
|
40
|
+
metrics = redis.lrange("profit:metric:some_foo_measurement", 0, -1)
|
41
|
+
metric = JSON.parse(metrics.first)
|
42
|
+
expect(metric['start_time']).to be_within(1).of(now.to_i)
|
43
|
+
end
|
44
|
+
|
29
45
|
describe "#ctx" do
|
30
46
|
|
31
47
|
it "is a ZMQ context" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: profit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -155,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
segments:
|
157
157
|
- 0
|
158
|
-
hash:
|
158
|
+
hash: 3230377706351225378
|
159
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
segments:
|
166
166
|
- 0
|
167
|
-
hash:
|
167
|
+
hash: 3230377706351225378
|
168
168
|
requirements: []
|
169
169
|
rubyforge_project:
|
170
170
|
rubygems_version: 1.8.23
|