activejob-traceable 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf1e8505d754e1c97ab23442354f976b42df0a191d12a74c1acf1aad90e35535
4
- data.tar.gz: c83de6f7b2ce7e79b6495bc84f572d3dd7a64eda882991f165cd7010ee878218
3
+ metadata.gz: 3cb378813a2f5765ca4f61d2ddd47f20eb51d12a459999e9097ad48dee946b3f
4
+ data.tar.gz: '0290962714ba0b3da20c57dff9d494b91e11158b7da115f5a258cac7d89e2949'
5
5
  SHA512:
6
- metadata.gz: bb48de5a1f48ff16d8af9bdf648838eb201c6386fe3104545280ac40e34b499ebb75e3cb5e1853cf1c237390573f9e34beee26ae85fd3d229ac6d53bf645fae6
7
- data.tar.gz: b2fbb9d54f9c1a79694893d4701adad57269f3b713ec3ccd37b8bbc314829fdd9189d7c698d8e3877c8b579b17d430dc8d115cdffe33645b3b7de7260ad28d12
6
+ metadata.gz: d436c1d712b26ca84ad773d2d1c5b9514a368c59a35a8dfa521821544d73470792602226bc9c8c9f2e5ec2cbfff7da2bc0d6dbdc87d7e617525890755cfe5557
7
+ data.tar.gz: acba39bed024643d06b5d15e87f09d6b991a48b8c3379068e570ac5b3b0f72b044ce4b724bb105e1fa98821a31e2d4f869209c8897f8ccc636190c273fda6866
@@ -14,15 +14,26 @@ module ActiveJob
14
14
  module_function
15
15
 
16
16
  def tracing_info_getter=(lambda)
17
- raise 'Tracing info getter should be callable' unless lambda.respond_to?(:call)
17
+ if lambda
18
+ raise 'Tracing info getter should be callable' unless lambda.respond_to?(:call)
19
+ raise 'Tracing info getter should contain a hash' unless lambda.call.is_a?(Hash)
18
20
 
19
- @tracing_info_getter = lambda
21
+ @tracing_info_getter = lambda
22
+ else
23
+ # Resets the value
24
+ @tracing_info_getter = nil
25
+ end
20
26
  end
21
27
 
22
28
  def tracing_info_setter=(lambda)
23
- raise 'Tracing info setter should be callable' unless lambda.respond_to?(:call)
29
+ if lambda
30
+ raise 'Tracing info setter should be callable' unless lambda.respond_to?(:call)
24
31
 
25
- @tracing_info_setter = lambda
32
+ @tracing_info_setter = lambda
33
+ else
34
+ # Resets the value
35
+ @tracing_info_setter = nil
36
+ end
26
37
  end
27
38
  end
28
39
  end
@@ -9,9 +9,8 @@ module ActiveJob
9
9
  private
10
10
 
11
11
  def tag_logger(*tags)
12
- if ActiveJob::Traceable.tracing_info_getter.respond_to?(:call)
13
- tags << ActiveJob::Traceable.tracing_info_getter.call
14
- end
12
+ tags << ActiveJob::Traceable.tracing_info_getter.call.values.compact
13
+ tags.flatten!
15
14
 
16
15
  if logger.respond_to?(:tagged)
17
16
  tags.unshift 'ActiveJob' unless logger_tagged_by_active_job?
@@ -10,7 +10,7 @@ module ActiveJob
10
10
  def initialize(*arguments)
11
11
  super(*arguments)
12
12
 
13
- @tracing_info = Traceable.tracing_info_getter.call if Traceable.tracing_info_getter.respond_to?(:call)
13
+ @tracing_info = Traceable.tracing_info_getter.call
14
14
  end
15
15
 
16
16
  def serialize
@@ -20,14 +20,22 @@ module ActiveJob
20
20
  def deserialize(job_data)
21
21
  super(job_data)
22
22
 
23
- self.tracing_info = job_data['tracing_info']
23
+ if job_data['tracing_info'].is_a?(Hash)
24
+ self.tracing_info = job_data['tracing_info']
25
+ end
24
26
 
25
- Traceable.tracing_info_setter.call(tracing_info) if Traceable.tracing_info_setter.respond_to?(:call)
27
+ Traceable.tracing_info_setter.call(tracing_info)
26
28
  end
27
29
  end
28
30
 
29
31
  class << self
30
- attr_accessor :tracing_info_getter, :tracing_info_setter
32
+ def tracing_info_getter
33
+ @tracing_info_getter || -> { {} }
34
+ end
35
+
36
+ def tracing_info_setter
37
+ @tracing_info_setter || -> {}
38
+ end
31
39
  end
32
40
  end
33
41
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveJob
4
4
  module Traceable
5
- VERSION = '0.3.1'
5
+ VERSION = '0.3.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob-traceable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qonto team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-13 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob