trailer 0.1.5 → 0.2.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
2
  SHA256:
3
- metadata.gz: '080993ef6144050d45a1c16f07593acdfa29c99fd8b9a6bf5166e7bcabecd336'
4
- data.tar.gz: '09e3d367d1246daa91c7acfca32d37d2863ab7f758d5956f948c0f067ce3d9aa'
3
+ metadata.gz: 19aa44602d0f21dcbc370fdd468fb3d4c47c07f51b4f971f52b36f418c615985
4
+ data.tar.gz: 7c15e53a79a627c50c6324f535f1280c63afe4d80771fd8b75d3392bbfb33612
5
5
  SHA512:
6
- metadata.gz: 789c1083fedc2c1c04972d0f96c35126768ac92203460da24e2fc0734144f36af708028a87db03bfe3921a583e67a28c10695c97f5f598572035e63a53ea63cf
7
- data.tar.gz: e93b1ad62ea77c1247ab07d27d9b324b27dd44be65515ee84eaca663bfc57e13b78c4a8bb368e0b172fcdc872da8889c5aef97f28f0ac555371c211b40f98982
6
+ metadata.gz: 715dfc4116b0b815e171ea17ca8a78c007fd1687e5888b51c8ceb29a737efd0f14c9c0bd940ff9650d837419d2dd77feeb7c403beb9eb4ae1d7af4e3411c8c53
7
+ data.tar.gz: 5c25042615eaffc24254784077cd76845db1e7880445a2ae422a19181b4454d9fe37735d3de00f0f36048180c72e878a9bee98abd6e490a38bbeb4777ed2eb5f
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 - 2020-09-28
4
+
5
+ ### Features
6
+
7
+ * Allow tracing without providing a block. ([#4])
8
+
9
+ [#4]: https://github.com/shuttlerock/trailer/pull/4
10
+
3
11
  ## 0.1.5 - 2020-09-08
4
12
 
5
13
  ### Features
data/README.md CHANGED
@@ -281,6 +281,20 @@ def add(a, b)
281
281
  end
282
282
  ```
283
283
 
284
+ You can use any of the trace methods without providing a block:
285
+
286
+ ```
287
+ class Order < ApplicationRecord
288
+ include Trailer::Concern
289
+
290
+ after_update_commit :trace_state_change, if: -> { saved_change_to_state? }
291
+
292
+ def trace_state_change
293
+ trace_class(self, state_was: state_was)
294
+ end
295
+ end
296
+ ```
297
+
284
298
 
285
299
  ### No Rails?
286
300
 
@@ -12,7 +12,11 @@ module Trailer
12
12
  # instance, query, etc (eg. current_user, 'Article#submit', 'http://example.com/articles').
13
13
  # @param tags Hash - Extra tags which should be tracked (eg. { method: 'GET' }).
14
14
  def trace_event(event, resource = nil, **tags, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
15
- return yield block unless Trailer.enabled?
15
+ unless Trailer.enabled?
16
+ return yield block if block_given?
17
+
18
+ return
19
+ end
16
20
 
17
21
  event = Trailer::Utility.resource_name(event) unless event.is_a?(String) || event.is_a?(Symbol)
18
22
 
@@ -49,7 +53,7 @@ module Trailer
49
53
 
50
54
  # Record how long the operation takes, in milliseconds.
51
55
  started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
52
- result = yield block
56
+ result = yield block if block_given?
53
57
  tags[:duration] = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at) * 1_000).ceil
54
58
 
55
59
  # Put the keys in alphabetical order, with the event and resource first.
@@ -69,7 +73,7 @@ module Trailer
69
73
  # @param tags Hash - Extra tags which should be tracked (eg. { method: 'GET' }).
70
74
  def trace_class(resource = nil, **tags, &block)
71
75
  trace_event(self.class.name, resource, **tags) do
72
- yield block
76
+ yield block if block_given?
73
77
  end
74
78
  end
75
79
 
@@ -84,7 +88,7 @@ module Trailer
84
88
  calling_klass = self.class.name
85
89
  calling_method = caller(1..1).first[/`.*'/][1..-2]
86
90
  trace_event("#{calling_klass}##{calling_method}", resource, **tags) do
87
- yield block
91
+ yield block if block_given?
88
92
  end
89
93
  end
90
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trailer
4
- VERSION = '0.1.5'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Perrett
@@ -34,7 +34,7 @@ cert_chain:
34
34
  3Um/SScB6alBpv/eTa/qPXa+S84pZDU6kFDasnH7GEl6jYlVxZbzpHUIvkDIOp5J
35
35
  6O1XOcLc39AfX5etu1WZ+wx3xUzux0oqS6rXcl63HmuKe8Son7RqJQ==
36
36
  -----END CERTIFICATE-----
37
- date: 2020-09-08 00:00:00.000000000 Z
37
+ date: 2020-09-28 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: aws-sdk-cloudwatchlogs
metadata.gz.sig CHANGED
Binary file