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 +4 -4
- data/.circleci/config.yml +21 -1
- data/README.md +7 -1
- data/lib/pwwka/configuration.rb +2 -0
- data/lib/pwwka/logging.rb +4 -1
- data/lib/pwwka/version.rb +1 -1
- data/spec/unit/logging_spec.rb +38 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91b93a22ea33ffd0151667910c29af13adaf2872c28327ae5af4aff03e9beb64
|
4
|
+
data.tar.gz: 7c8bc1db3fcb3045caafbba21d8ca94838756c347951418535543a7045162ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac5525cd3bdf5a162d0979b58b5f750a3bdd59074d703997bfb5b574f864491430148dd9ba84afe95cd13607ed14244e792f22582004122020411cb6498fb047
|
7
|
+
data.tar.gz: ccdd3938884c1f0d247176baa8c919257154e9126d347e0541703d5b2f860b39d425d8ddc96dfe2fd2fd3a18787a425942bfe7f97daa6e5d48e037188f9507fd
|
data/.circleci/config.yml
CHANGED
@@ -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)[-\.]?\
|
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
|
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
|
data/lib/pwwka/configuration.rb
CHANGED
@@ -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
|
data/lib/pwwka/logging.rb
CHANGED
@@ -22,7 +22,10 @@ module Pwwka
|
|
22
22
|
params[:payload] = "[omitted]" if params[:payload]
|
23
23
|
end
|
24
24
|
message = format % params
|
25
|
-
|
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
|
data/lib/pwwka/version.rb
CHANGED
data/spec/unit/logging_spec.rb
CHANGED
@@ -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.
|
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-
|
18
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bunny
|