trailer 0.1.5 → 0.2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +8 -0
- data/README.md +14 -0
- data/lib/trailer/concern.rb +8 -4
- data/lib/trailer/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19aa44602d0f21dcbc370fdd468fb3d4c47c07f51b4f971f52b36f418c615985
|
4
|
+
data.tar.gz: 7c15e53a79a627c50c6324f535f1280c63afe4d80771fd8b75d3392bbfb33612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 715dfc4116b0b815e171ea17ca8a78c007fd1687e5888b51c8ceb29a737efd0f14c9c0bd940ff9650d837419d2dd77feeb7c403beb9eb4ae1d7af4e3411c8c53
|
7
|
+
data.tar.gz: 5c25042615eaffc24254784077cd76845db1e7880445a2ae422a19181b4454d9fe37735d3de00f0f36048180c72e878a9bee98abd6e490a38bbeb4777ed2eb5f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
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
|
|
data/lib/trailer/concern.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/trailer/version.rb
CHANGED
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.
|
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-
|
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
|