dry-monitor 1.0.0 → 1.0.1

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
2
  SHA256:
3
- metadata.gz: 02b2ad507bf711d0d3f5ab6bb2ea574afff379851d1ac3897f8bce1aa984dba7
4
- data.tar.gz: 0ef87b325ef52c171a11e385b97158d4e0744508b767a83beb581abb51e6ead5
3
+ metadata.gz: afa00138c4dc7ce920300c3d5ea5e88bfe95a32d8a195b55398a5ae8896c734a
4
+ data.tar.gz: d2486b5a1dbdb10630969e46c52cf0b3e4c2db66cf1576a64a6dc9486e6c6d93
5
5
  SHA512:
6
- metadata.gz: b449e83e90980e65b0e38996a257338409797e4dabd2ed3a632cea63fa157db1cd07878c5979698727300ad2c1ac5bc5d1eec9a32f432bcb7c5e816162043c4f
7
- data.tar.gz: e73a5defc0e6cda1e5bb0f27c992f9d41fc6ed064f51f670130e9863951cf8f984a6b880df68f74a95face1af6a15b20a28a65f5060ddcc3cc94f5f8b02e9057
6
+ metadata.gz: 74d9e1d40b2c51fdf96cff797eb66c4c16b3d38924b226d83045384de3c48695f05b15b485930513924957c5a38862496c6e541b28a6b9235be0f7a2cecbe0c6
7
+ data.tar.gz: e049809c0246586f57195438dffef39c3e521fb8793e7f1a772b96185fdc87d97f2170c540517cb22a1984f0772d7a815672e44e27149313f3f98c45a04c1799
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 1.0.1 2022-11-17
4
+
5
+
6
+ ### Added
7
+
8
+ - Extend Clock with support for configurable units (via #50) (@solnic)
9
+
10
+
11
+ [Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-monitor/compare/v1.0.0...v1.0.1)
12
+
3
13
  ## 1.0.0 2022-11-04
4
14
 
5
15
 
@@ -4,6 +4,11 @@ module Dry
4
4
  module Monitor
5
5
  # @api public
6
6
  class Clock
7
+ # @api private
8
+ def initialize(unit: :millisecond)
9
+ @unit = unit
10
+ end
11
+
7
12
  # @api public
8
13
  def measure
9
14
  start = current
@@ -13,7 +18,7 @@ module Dry
13
18
 
14
19
  # @api public
15
20
  def current
16
- Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
21
+ Process.clock_gettime(Process::CLOCK_MONOTONIC, @unit)
17
22
  end
18
23
  end
19
24
  end
@@ -12,9 +12,9 @@ module Dry
12
12
 
13
13
  attr_reader :id, :clock
14
14
 
15
- def initialize(id)
15
+ def initialize(id, clock: CLOCK)
16
16
  @id = id
17
- @clock = CLOCK
17
+ @clock = clock
18
18
  end
19
19
 
20
20
  def start(event_id, payload)
@@ -16,7 +16,7 @@ module Dry
16
16
  QUERY_STRING = "QUERY_STRING"
17
17
 
18
18
  START_MSG = %(Started %s "%s" for %s at %s)
19
- STOP_MSG = %(Finished %s "%s" for %s in %sms [Status: %s]\n)
19
+ STOP_MSG = %(Finished %s "%s" for %s in %s [Status: %s]\n)
20
20
  QUERY_MSG = %( Query parameters )
21
21
  FILTERED = "[FILTERED]"
22
22
 
@@ -14,12 +14,13 @@ module Dry
14
14
 
15
15
  attr_reader :app, :notifications
16
16
 
17
- def initialize(*args)
17
+ def initialize(*args, clock: CLOCK)
18
18
  @notifications, @app = *args
19
+ @clock = clock
19
20
  end
20
21
 
21
- def new(app, *_args, &_block)
22
- self.class.new(notifications, app)
22
+ def new(app, *_args, clock: @clock, &_block)
23
+ self.class.new(notifications, app, clock: clock)
23
24
  end
24
25
 
25
26
  def on(event_id, &block)
@@ -32,7 +33,7 @@ module Dry
32
33
 
33
34
  def call(env)
34
35
  notifications.start(REQUEST_START, env: env)
35
- response, time = CLOCK.measure { app.call(env) }
36
+ response, time = @clock.measure { app.call(env) }
36
37
  notifications.stop(REQUEST_STOP, env: env, time: time, status: response[0])
37
38
  response
38
39
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Monitor
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable