pwwka 0.23.0 → 0.24.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: 267500c638d786f3a583dd73661818565dcd40b778ee96a788fe9604d3e898ed
4
- data.tar.gz: 6e64b966616a2650f7c78702981cc209e571625c554b2da2140d1aa8610fdee6
3
+ metadata.gz: 91b93a22ea33ffd0151667910c29af13adaf2872c28327ae5af4aff03e9beb64
4
+ data.tar.gz: 7c8bc1db3fcb3045caafbba21d8ca94838756c347951418535543a7045162ade
5
5
  SHA512:
6
- metadata.gz: 997e9a6c703e482ec343e024f72d2ac0b12602b7b7578ee9b66675216a8fa18e6f30bddea80ecc9b1b63f8173f5a73296dc9f847017e7bb3e554216f416c42c3
7
- data.tar.gz: 67a92f5b32a3be3d311dad301a15d929b002d5ca347aa1b792c07ce1bf67264929e7f6ed218476a2a4dcf1dc8818b16a3ff6903112de075e02609bab4a370659
6
+ metadata.gz: ac5525cd3bdf5a162d0979b58b5f750a3bdd59074d703997bfb5b574f864491430148dd9ba84afe95cd13607ed14244e792f22582004122020411cb6498fb047
7
+ data.tar.gz: ccdd3938884c1f0d247176baa8c919257154e9126d347e0541703d5b2f860b39d425d8ddc96dfe2fd2fd3a18787a425942bfe7f97daa6e5d48e037188f9507fd
@@ -27,6 +27,11 @@ jobs:
27
27
  working_directory: "~/pwwka"
28
28
  steps:
29
29
  - checkout
30
+ - run:
31
+ name: Check for Gemfile.lock presence
32
+ command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
33
+ https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
34
+ 1>&2 ; exit 1 ; else exit 0 ; fi '
30
35
  - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
31
36
  - run: bundle install --full-index
32
37
  - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
@@ -51,6 +56,11 @@ jobs:
51
56
  working_directory: "~/pwwka"
52
57
  steps:
53
58
  - checkout
59
+ - run:
60
+ name: Check for Gemfile.lock presence
61
+ command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
62
+ https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
63
+ 1>&2 ; exit 1 ; else exit 0 ; fi '
54
64
  - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
55
65
  - run: bundle install --full-index
56
66
  - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
@@ -75,6 +85,11 @@ jobs:
75
85
  working_directory: "~/pwwka"
76
86
  steps:
77
87
  - checkout
88
+ - run:
89
+ name: Check for Gemfile.lock presence
90
+ command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
91
+ https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
92
+ 1>&2 ; exit 1 ; else exit 0 ; fi '
78
93
  - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
79
94
  - run: bundle install --full-index
80
95
  - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
@@ -99,6 +114,11 @@ jobs:
99
114
  working_directory: "~/pwwka"
100
115
  steps:
101
116
  - checkout
117
+ - run:
118
+ name: Check for Gemfile.lock presence
119
+ command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
120
+ https://github.com/stitchfix/eng-wiki/blob/master/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
121
+ 1>&2 ; exit 1 ; else exit 0 ; fi '
102
122
  - run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
103
123
  - run: bundle install --full-index
104
124
  - run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
@@ -126,7 +146,7 @@ workflows:
126
146
  - ruby-2.6.6-rails-5.2
127
147
  filters:
128
148
  tags:
129
- only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\d*)?$/
149
+ only: /^[0-9]+\.[0-9]+\.[0-9]+(\.?(RC|rc)[-\.]?\w*)?$/
130
150
  branches:
131
151
  ignore: /.*/
132
152
  - ruby-2.7.1-rails-6.0:
data/README.md CHANGED
@@ -435,7 +435,7 @@ If you use [Resque][resque], and you wish to handle messages in a resque job, yo
435
435
 
436
436
  Note that you must provide `@queue` in your job. `QueueResqueJobHandler` doesn't support setting a custom queue at enqueue-time (PRs welcome :).
437
437
 
438
- Note that if you were using this library before version 0.12.0, your job would only be given the payload. If you change your job to accept exatly three arguments, you will be given the payload, routing key, and message properties. If any of those arguments are optional, you will need to set `PWWKA_QUEUE_EXTENDED_INFO` to `"true"` to force pwwka to pass those along. Without it, your job only gets the payload to avoid breaking legacy consumers.
438
+ Note that if you were using this library before version 0.12.0, your job would only be given the payload. If you change your job to accept exactly three arguments, you will be given the payload, routing key, and message properties. If any of those arguments are optional, you will need to set `PWWKA_QUEUE_EXTENDED_INFO` to `"true"` to force pwwka to pass those along. Without it, your job only gets the payload to avoid breaking legacy consumers.
439
439
 
440
440
  3. Profit!
441
441
 
@@ -532,6 +532,12 @@ Pwwka.configuration.payload_logging = :error # Only log payloads for ERROR or FA
532
532
  Pwwka.configuration.payload_logging = :fatal # Only log payloads for FATAL messages
533
533
  ```
534
534
 
535
+ You can also hook into logging by passing a hash containing keys of strings to match and corresponding `Proc` objects for the logger to execute instead of logging a message. The `Proc` will be called with the original message string that was to be logged and the params specific for that log event. So, if for instance, you wanted to emit a count metric to your monitoring system instead of logging each processed message you could set the configuration:
536
+
537
+ ```ruby
538
+ Pwwka.configuration.log_hooks = { 'Processed Message on' => ->(message, params){ $stats.count('message_processed') } }
539
+ ```
540
+
535
541
  #### Manual monitoring
536
542
 
537
543
  RabbitMQ has a web interface for checking out the health of connections, channels, exchanges and queues. Your RabbitMQ provider should
@@ -10,6 +10,7 @@ module Pwwka
10
10
  attr_accessor :delayed_exchange_name
11
11
  attr_accessor :logger
12
12
  attr_accessor :log_level
13
+ attr_accessor :log_hooks
13
14
  attr_accessor :options
14
15
  attr_accessor :background_job_processor
15
16
  attr_accessor :send_message_resque_backoff_strategy
@@ -26,6 +27,7 @@ module Pwwka
26
27
  @delayed_exchange_name = "pwwka.delayed.#{Pwwka.environment}"
27
28
  @logger = MonoLogger.new(STDOUT)
28
29
  @log_level = :info
30
+ @log_hooks = {}
29
31
  @options = {}
30
32
  @send_message_resque_backoff_strategy = [5, #intermittent glitch?
31
33
  60, # quick interruption
@@ -22,7 +22,10 @@ module Pwwka
22
22
  params[:payload] = "[omitted]" if params[:payload]
23
23
  end
24
24
  message = format % params
25
- logger.send(level,message)
25
+
26
+ if Pwwka.configuration.log_hooks.select { |key, _value| message.match key }.each { |_key, value| value.call(message, params) }.empty?
27
+ logger.send(level,message)
28
+ end
26
29
  end
27
30
  end
28
31
  end
@@ -1,4 +1,4 @@
1
1
  module Pwwka
2
- VERSION = '0.23.0'
2
+ VERSION = '0.24.0'
3
3
  end
4
4
 
@@ -93,6 +93,44 @@ describe Pwwka::Logging do
93
93
  expect(logger).to have_received(:error).with("This is also the payload: [omitted]")
94
94
  end
95
95
  end
96
+
97
+ context "log_hook matching" do
98
+ def test_func(message, params)
99
+ end
100
+
101
+ before do
102
+ Pwwka.configuration.log_hooks = { "test message" => ->(message, params){ test_func(message, params) } }
103
+ end
104
+
105
+ after do
106
+ Pwwka.configuration.log_hooks = {}
107
+ end
108
+
109
+ context "message matches hook" do
110
+ it "overrides logging" do
111
+ ForLogging.logf("test message", {})
112
+
113
+ expect(logger).not_to have_received(:info)
114
+ end
115
+
116
+ it "calls the hook" do
117
+ allow(self).to receive(:test_func)
118
+ test_params = { param: :test }
119
+
120
+ ForLogging.logf("test message", test_params)
121
+
122
+ expect(self).to have_received(:test_func).with("test message", test_params)
123
+ end
124
+ end
125
+
126
+ context "message doesn't match hook" do
127
+ it "logs as normal" do
128
+ ForLogging.logf("other message", {})
129
+
130
+ expect(logger).to have_received(:info).with("other message")
131
+ end
132
+ end
133
+ end
96
134
  end
97
135
 
98
136
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwwka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stitch Fix Engineering
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2020-07-01 00:00:00.000000000 Z
18
+ date: 2020-08-25 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bunny