step-track 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 766408f026e5cdf10e0ac311351d574a86113e32
4
- data.tar.gz: c03e4c76aea397f91bd903e6680e17c53c5a7103
2
+ SHA256:
3
+ metadata.gz: 1f2cf3c8e226306a38bc949515f9860a9728b49d6e366a68cc65a65ec1ce3965
4
+ data.tar.gz: c4f55d097d5145106313637d079acd21d3e50ce7eb026cc4f7ffa90a6577d285
5
5
  SHA512:
6
- metadata.gz: e8ab58e6ad12f5c5741d74587158cba05647c9e8d83bba5afdfb15711b031748e5cf6079144e854c54e441c26bfad9f10711accb8127475a6d6e0ea5a13fb2a5
7
- data.tar.gz: efc96970f43e2e0de3605dfd3765cb2b2f19ab26c913c22cc3d22ce79b074d0c6f6a1aff6a3c12fdee965cf49d76472477cf64c2d02a981b0838ea3317839eba
6
+ metadata.gz: 95f4f5509d36026b04843cd849be214e9c55527bd8b4a1f31667ba8edb340ee5a1e4225c3a606acacf04e823715139fb2ef85ac268375aa3b65ac769872cc936
7
+ data.tar.gz: 4a15c7da79f2bfd36e3b1a8b8210dff5c63e0d1ed323f471060dc01042a6b7daf36b1b01924d803311606d8dc1a9bfba73ff880f2b7e62fd7ff18ca28ca67590
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "date"
4
+
3
5
  module StepTrack
4
6
  extend self
5
7
 
@@ -20,7 +22,7 @@ module StepTrack
20
22
  track_id: config[:track_id] || Thread.current.object_id.to_s,
21
23
  steps: [],
22
24
  callback: Proc.new,
23
- time: Time.now,
25
+ time: DateTime.now,
24
26
  caller: config&.[](:caller) || get_caller.()
25
27
  }.merge(DEFAULT_CONFIG).merge(config)
26
28
  end
@@ -31,9 +33,9 @@ module StepTrack
31
33
  merge_step = track_ref[:steps].pop if payload.delete(track_ref[:merge_key])
32
34
  last_step = track_ref[:steps].last
33
35
  track_ref[:steps] << (merge_step || {}).merge(
34
- split: Time.now.to_f - (last_step&.[](:time) || track_ref[:time]).to_f,
35
- duration: Time.now.to_f - track_ref[:time].to_f,
36
- time: Time.now,
36
+ split: Time.now.to_f - (last_step&.[](:time) || track_ref[:time]).to_time.to_f,
37
+ duration: Time.now.to_f - track_ref[:time].to_time.to_f,
38
+ time: DateTime.now,
37
39
  caller: merge_step&.[](:caller) || get_caller.(),
38
40
  step_name: merge_step&.[](:step_name) || name
39
41
  ).merge(payload)
@@ -44,11 +46,12 @@ module StepTrack
44
46
  track_ref = Thread.current[ref(track)]
45
47
  Thread.current[ref(track)] = nil
46
48
  steps = track_ref.delete(:steps)
47
- steps.each { |step| step.delete(:time) }
49
+ steps.each { |s| s[:timestamp] = s.delete(:time).iso8601 }
48
50
  result = {
49
51
  step_count: steps.count,
50
52
  caller: track_ref[:caller],
51
- duration: Time.now.to_f - track_ref[:time].to_f,
53
+ duration: Time.now.to_f - track_ref[:time].to_time.to_f,
54
+ timestamp: track_ref[:time].iso8601,
52
55
  track_id: track_ref[:track_id]
53
56
  }
54
57
  if err = steps.detect { |s| s.key?(track_ref[:error_key]) }
@@ -1,3 +1,3 @@
1
1
  module StepTrack
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -21,8 +21,8 @@ describe "StepTrack" do
21
21
  "steps is no empty array #{data[:steps].inspect}"
22
22
  assert data[:callback].is_a?(Proc),
23
23
  "callback is no proc #{data[:callback].inspect}"
24
- assert data[:time] <= Time.now,
25
- "time #{data[:time].inspect} > #{Time.now.inspect}"
24
+ assert data[:time] <= DateTime.now,
25
+ "time #{data[:time].inspect} > #{DateTime.now.inspect}"
26
26
  assert_equal data[:track_id], Thread.current.object_id.to_s,
27
27
  "track id is #{StepTrack.track_id("test")}"
28
28
  refute_empty data[:caller], "caller is empty"
@@ -116,6 +116,11 @@ describe "StepTrack" do
116
116
  assert_match %r{#{Regexp.escape(__FILE__)}}, result[:caller]
117
117
  end
118
118
 
119
+ it "sets a timestamp" do
120
+ result = StepTrack.done("test")
121
+ assert_match %r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}}, result[:timestamp]
122
+ end
123
+
119
124
  it "does not merge final step into results" do
120
125
  result = StepTrack.done("test")
121
126
  assert !result.key?(:gnu), "merged gnu into result"
@@ -130,7 +135,7 @@ describe "StepTrack" do
130
135
 
131
136
  it "enumerates every step into result" do
132
137
  result = StepTrack.done("test")
133
- expected_key_parts = [:i, :split, :duration, :caller]
138
+ expected_key_parts = [:i, :split, :duration, :timestamp, :caller]
134
139
 
135
140
  ["step", "last"].each_with_index do |n, i|
136
141
  expected_keys = expected_key_parts.map { |k| "step_#{n}_#{k}".to_sym }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: step-track
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Geier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -54,8 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  requirements: []
57
- rubyforge_project:
58
- rubygems_version: 2.5.2.3
57
+ rubygems_version: 3.0.3
59
58
  signing_key:
60
59
  specification_version: 4
61
60
  summary: Tracks data fragments across the application