contextualized_logs 0.0.1.pre.alpha → 0.0.2.pre.alpha
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
- data/README.md +217 -155
- data/app/controllers/application_controller.rb +1 -0
- data/app/controllers/concerns/datadog_set_trace_details.rb +36 -0
- data/app/controllers/custom_context_controller.rb +17 -0
- data/app/controllers/model_controller.rb +1 -1
- data/app/models/model.rb +1 -1
- data/app/workers/model_worker.rb +2 -2
- data/config/initializers/contextualized_logs.rb +23 -0
- data/config/initializers/datadog.rb +17 -0
- data/config/initializers/sidekiq.rb +13 -13
- data/config/routes.rb +1 -0
- data/db/development.sqlite3 +0 -0
- data/lib/contextualized_logs.rb +25 -0
- data/lib/contextualized_logs/config.rb +27 -0
- data/lib/contextualized_logs/contextualized_controller.rb +54 -40
- data/lib/contextualized_logs/contextualized_logger.rb +74 -67
- data/lib/contextualized_logs/contextualized_model.rb +28 -24
- data/lib/contextualized_logs/contextualized_worker.rb +52 -18
- data/lib/contextualized_logs/current_context.rb +69 -67
- data/lib/contextualized_logs/sidekiq/middleware/client/inject_current_context.rb +3 -3
- data/lib/contextualized_logs/sidekiq/middleware/server/restore_current_context.rb +3 -3
- data/lib/contextualized_logs/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d2a30eaa931eb9013ce4e8007229c24f71150d89d7399372820eb33e1e72deb
|
|
4
|
+
data.tar.gz: 1b7a809fb3ea83334a7248a97a63c9728b899400c8e5869d7be28a55379fc832
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1543991e0904103f8bd6dbf0fc791fa6fe6f8302aea6e49049ae49adbf35d352d5d226fc7075f48bbc956b9d7a2b7f7f136e0b9e980cd00a03be47658070552
|
|
7
|
+
data.tar.gz: 99b5866d81903a8bb4e7e3231acdd15931de535bb8297a2a6bd60c9c5ec9d7b397194b0f44f1f7e48ce9554962ab3a2174815033d736f6d4392d6ba89f4f517b
|
data/README.md
CHANGED
|
@@ -26,31 +26,30 @@ class MyController < ApplicationController
|
|
|
26
26
|
end
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
curl --referer 'referer' --user-agent 'user_agent' -H "Origin: http://localhost" http://localhost/my_controller?param=a
|
|
29
|
+
$ curl --referer "referer" --user-agent "user_agent" -H "Origin: http://localhost" http://localhost/my_controller?param=a
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
```json
|
|
33
32
|
{
|
|
34
|
-
syslog: {
|
|
35
|
-
env:
|
|
36
|
-
host:
|
|
33
|
+
"syslog": {
|
|
34
|
+
"env": "development",
|
|
35
|
+
"host": "localhost"
|
|
37
36
|
},
|
|
38
|
-
type:
|
|
39
|
-
time:
|
|
40
|
-
log_type:
|
|
41
|
-
resource_name:
|
|
42
|
-
http: {
|
|
43
|
-
referer:
|
|
44
|
-
request_id:
|
|
45
|
-
useragent:
|
|
46
|
-
origin:
|
|
37
|
+
"type": "INFO",
|
|
38
|
+
"time": "2020-04-24T19:52:51.452+02:00",
|
|
39
|
+
"log_type": "log",
|
|
40
|
+
"resource_name": "mycontroller_show",
|
|
41
|
+
"http": {
|
|
42
|
+
"referer": "referer",
|
|
43
|
+
"request_id": "xxxx-xxxx-xxxx-xxxx",
|
|
44
|
+
"useragent": "user_agent",
|
|
45
|
+
"origin": "http://localhost"
|
|
47
46
|
},
|
|
48
|
-
network: {
|
|
49
|
-
client: {
|
|
50
|
-
ip:
|
|
51
|
-
remote_addr:
|
|
52
|
-
remote_ip:
|
|
53
|
-
x_forwarded_for:
|
|
47
|
+
"network": {
|
|
48
|
+
"client": {
|
|
49
|
+
"ip": "127.0.0.1",
|
|
50
|
+
"remote_addr": "127.0.0.1",
|
|
51
|
+
"remote_ip": "127.0.0.1",
|
|
52
|
+
"x_forwarded_for": "127.0.0.1"
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -64,7 +63,7 @@ end
|
|
|
64
63
|
|
|
65
64
|
class UserController < ApplicationController
|
|
66
65
|
include ContextualizedLogs::ContextualizedController
|
|
67
|
-
|
|
66
|
+
contextualize_model true
|
|
68
67
|
|
|
69
68
|
def show
|
|
70
69
|
User.find(params[:id])
|
|
@@ -72,31 +71,30 @@ class UserController < ApplicationController
|
|
|
72
71
|
end
|
|
73
72
|
```
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
curl http://localhost/users/1
|
|
74
|
+
$ curl http://localhost/users/1
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
```json
|
|
79
77
|
{
|
|
80
|
-
syslog: {
|
|
81
|
-
env:
|
|
82
|
-
host:
|
|
78
|
+
"syslog": {
|
|
79
|
+
"env": "development",
|
|
80
|
+
"host": "localhost"
|
|
83
81
|
},
|
|
84
|
-
type:
|
|
85
|
-
time:
|
|
86
|
-
log_type:
|
|
87
|
-
context_values: {
|
|
88
|
-
user_ids: [1]
|
|
82
|
+
"type": "INFO",
|
|
83
|
+
"time": "2020-04-24T19:52:51.452+02:00",
|
|
84
|
+
"log_type": "log",
|
|
85
|
+
"context_values": {
|
|
86
|
+
"user_ids": [1]
|
|
89
87
|
},
|
|
90
|
-
resource_name:
|
|
91
|
-
http: {
|
|
92
|
-
request_id:
|
|
88
|
+
"resource_name": "mycontroller_show",
|
|
89
|
+
"http": {
|
|
90
|
+
"request_id": "xxxx-xxxx-xxxx-xxxx"
|
|
93
91
|
},
|
|
94
|
-
network: {
|
|
95
|
-
client: {
|
|
96
|
-
ip:
|
|
97
|
-
remote_addr:
|
|
98
|
-
remote_ip:
|
|
99
|
-
x_forwarded_for:
|
|
92
|
+
"network": {
|
|
93
|
+
"client": {
|
|
94
|
+
"ip": "127.0.0.1",
|
|
95
|
+
"remote_addr": "127.0.0.1",
|
|
96
|
+
"remote_ip": "127.0.0.1",
|
|
97
|
+
"x_forwarded_for": "127.0.0.1"
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
}
|
|
@@ -118,7 +116,7 @@ end
|
|
|
118
116
|
|
|
119
117
|
class UserController < ApplicationController
|
|
120
118
|
include ContextualizedLogs::ContextualizedController
|
|
121
|
-
|
|
119
|
+
contextualize_model true
|
|
122
120
|
|
|
123
121
|
def show
|
|
124
122
|
user_id = params[:id]
|
|
@@ -130,8 +128,8 @@ end
|
|
|
130
128
|
class UserTrackerWorker
|
|
131
129
|
include Sidekiq::Worker
|
|
132
130
|
include ContextualizedLogs::ContextualizedWorker
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
contextualize_worker true
|
|
132
|
+
contextualize_model true
|
|
135
133
|
def self.contextualize_args(args)
|
|
136
134
|
{ user_id: args.first, action: args.last }
|
|
137
135
|
end
|
|
@@ -142,102 +140,107 @@ class UserTrackerWorker
|
|
|
142
140
|
end
|
|
143
141
|
```
|
|
144
142
|
|
|
145
|
-
|
|
146
|
-
curl http://localhost/users/1
|
|
143
|
+
$ curl http://localhost/users/1
|
|
147
144
|
|
|
148
|
-
|
|
145
|
+
```json
|
|
149
146
|
{
|
|
150
|
-
syslog: {
|
|
151
|
-
env:
|
|
152
|
-
host:
|
|
147
|
+
"syslog": {
|
|
148
|
+
"env": "development",
|
|
149
|
+
"host": "localhost"
|
|
153
150
|
},
|
|
154
|
-
type:
|
|
155
|
-
time:
|
|
156
|
-
log_type:
|
|
157
|
-
context_values: {
|
|
158
|
-
user_ids: [1]
|
|
151
|
+
"type": "INFO",
|
|
152
|
+
"time": "2020-04-24T19:52:51.452+02:00",
|
|
153
|
+
"log_type": "log",
|
|
154
|
+
"context_values": {
|
|
155
|
+
"user_ids": [1]
|
|
159
156
|
},
|
|
160
|
-
enqueued_jobs_ids: [
|
|
161
|
-
resource_name:
|
|
162
|
-
http: {
|
|
163
|
-
request_id:
|
|
157
|
+
"enqueued_jobs_ids": ["1234-xxxx-xxxx-xxxx"],
|
|
158
|
+
"resource_name": "mycontroller_show",
|
|
159
|
+
"http": {
|
|
160
|
+
"request_id": "xxxx-xxxx-xxxx-xxxx"
|
|
164
161
|
},
|
|
165
|
-
network: {
|
|
166
|
-
client: {
|
|
167
|
-
ip:
|
|
168
|
-
remote_addr:
|
|
169
|
-
remote_ip:
|
|
170
|
-
x_forwarded_for:
|
|
162
|
+
"network": {
|
|
163
|
+
"client": {
|
|
164
|
+
"ip": "127.0.0.1",
|
|
165
|
+
"remote_addr": "127.0.0.1",
|
|
166
|
+
"remote_ip": "127.0.0.1",
|
|
167
|
+
"x_forwarded_for": "127.0.0.1"
|
|
171
168
|
}
|
|
172
169
|
}
|
|
173
170
|
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
174
|
{
|
|
175
|
-
syslog: {
|
|
176
|
-
env:
|
|
177
|
-
host:
|
|
175
|
+
"syslog": {
|
|
176
|
+
"env": "development",
|
|
177
|
+
"host": "localhost"
|
|
178
178
|
},
|
|
179
|
-
type:
|
|
180
|
-
time:
|
|
181
|
-
log_type:
|
|
182
|
-
message:
|
|
183
|
-
job: {
|
|
184
|
-
worker:
|
|
185
|
-
id:
|
|
186
|
-
args: {
|
|
187
|
-
user_id: 1,
|
|
188
|
-
action:
|
|
179
|
+
"type": "INFO",
|
|
180
|
+
"time": "2020-04-24T19:52:51.452+02:00",
|
|
181
|
+
"log_type": "log",
|
|
182
|
+
"message": "sidekiq: completing job UserWorker: 1234-xxxx-xxxx-xxxx, on queue default",
|
|
183
|
+
"job": {
|
|
184
|
+
"worker": "UserWorker",
|
|
185
|
+
"id": "1234-xxxx-xxxx-xxxx",
|
|
186
|
+
"args": {
|
|
187
|
+
"user_id": 1,
|
|
188
|
+
"action": "show"
|
|
189
189
|
}
|
|
190
|
-
}
|
|
191
|
-
context_values: {
|
|
192
|
-
user_ids: [1],
|
|
193
|
-
user_tracker_ids: [1]
|
|
194
190
|
},
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
"context_values": {
|
|
192
|
+
"user_ids": [1],
|
|
193
|
+
"user_tracker_ids": [1]
|
|
194
|
+
},
|
|
195
|
+
"enqueued_jobs_ids": ["xxxx-xxxx-xxxx-xxxx"],
|
|
196
|
+
"resource_name": "mycontroller_show",
|
|
197
|
+
"http": {
|
|
198
|
+
"request_id": "xxxx-xxxx-xxxx-xxxx"
|
|
199
199
|
},
|
|
200
|
-
network: {
|
|
201
|
-
client: {
|
|
202
|
-
ip:
|
|
203
|
-
remote_addr:
|
|
204
|
-
remote_ip:
|
|
205
|
-
x_forwarded_for:
|
|
200
|
+
"network": {
|
|
201
|
+
"client": {
|
|
202
|
+
"ip": "127.0.0.1",
|
|
203
|
+
"remote_addr": "127.0.0.1",
|
|
204
|
+
"remote_ip": "127.0.0.1",
|
|
205
|
+
"x_forwarded_for": "127.0.0.1"
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
```json
|
|
209
212
|
{
|
|
210
|
-
syslog: {
|
|
211
|
-
env:
|
|
212
|
-
host:
|
|
213
|
+
"syslog": {
|
|
214
|
+
"env": "development",
|
|
215
|
+
"host": "localhost"
|
|
213
216
|
},
|
|
214
|
-
type:
|
|
215
|
-
time:
|
|
216
|
-
log_type:
|
|
217
|
-
message:
|
|
218
|
-
job: {
|
|
219
|
-
worker:
|
|
220
|
-
id:
|
|
221
|
-
args: {
|
|
222
|
-
user_id: 1,
|
|
223
|
-
action:
|
|
217
|
+
"type": "INFO",
|
|
218
|
+
"time": "2020-04-24T19:52:51.452+02:00",
|
|
219
|
+
"log_type": "log",
|
|
220
|
+
"message": "sidekiq: completing job UserWorker: 1234-xxxx-xxxx-xxxx, on queue default",
|
|
221
|
+
"job": {
|
|
222
|
+
"worker": "UserWorker",
|
|
223
|
+
"id": "1234-xxxx-xxxx-xxxx",
|
|
224
|
+
"args": {
|
|
225
|
+
"user_id": 1,
|
|
226
|
+
"action": "show"
|
|
224
227
|
}
|
|
225
|
-
}
|
|
226
|
-
context_values: {
|
|
227
|
-
user_ids: [1],
|
|
228
|
-
user_tracker_ids: [1]
|
|
229
228
|
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
"context_values": {
|
|
230
|
+
"user_ids": [1],
|
|
231
|
+
"user_tracker_ids": [1]
|
|
232
|
+
},
|
|
233
|
+
"enqueued_jobs_ids": ["xxxx-xxxx-xxxx-xxxx"],
|
|
234
|
+
"resource_name": "mycontroller_show",
|
|
235
|
+
"http": {
|
|
236
|
+
"request_id": "xxxx-xxxx-xxxx-xxxx"
|
|
234
237
|
},
|
|
235
|
-
network: {
|
|
236
|
-
client: {
|
|
237
|
-
ip:
|
|
238
|
-
remote_addr:
|
|
239
|
-
remote_ip:
|
|
240
|
-
x_forwarded_for:
|
|
238
|
+
"network": {
|
|
239
|
+
"client": {
|
|
240
|
+
"ip": "127.0.0.1",
|
|
241
|
+
"remote_addr": "127.0.0.1",
|
|
242
|
+
"remote_ip": "127.0.0.1",
|
|
243
|
+
"x_forwarded_for": "127.0.0.1"
|
|
241
244
|
}
|
|
242
245
|
}
|
|
243
246
|
}
|
|
@@ -246,23 +249,22 @@ curl http://localhost/users/1
|
|
|
246
249
|
## Demo
|
|
247
250
|
|
|
248
251
|
### start rails
|
|
249
|
-
|
|
250
|
-
bin/setup
|
|
251
|
-
bin/rails server
|
|
252
|
-
```
|
|
252
|
+
|
|
253
|
+
$ bin/setup
|
|
254
|
+
$ bin/rails server
|
|
253
255
|
|
|
254
256
|
### start sidekiq
|
|
255
|
-
|
|
256
|
-
bundle exec sidekiq
|
|
257
|
-
|
|
257
|
+
|
|
258
|
+
$ bundle exec sidekiq
|
|
259
|
+
|
|
258
260
|
|
|
259
261
|
### tail logs
|
|
260
|
-
|
|
261
|
-
tail -f log/development
|
|
262
|
-
```
|
|
262
|
+
|
|
263
|
+
$ tail -f log/development
|
|
263
264
|
|
|
264
265
|
### do some requests
|
|
265
|
-
|
|
266
|
+
|
|
267
|
+
```shell
|
|
266
268
|
curl -X POST -d '{"value": "value"}' -H 'Content-Type: application/json' "http://localhost:3000/model"
|
|
267
269
|
curl "http://localhost:3000/model/1"
|
|
268
270
|
curl "http://localhost:3000/model"
|
|
@@ -278,7 +280,7 @@ In order to enrich your logs, you needs to use (subclass of `ActiveSupport::Logg
|
|
|
278
280
|
> ContextualizedLogger logs by default some request metadata following Datadog naming convention
|
|
279
281
|
> https://docs.hq.com/logs/processing/attributes_naming_convention/#source-code
|
|
280
282
|
|
|
281
|
-
```
|
|
283
|
+
```ruby
|
|
282
284
|
Rails.application.configure do
|
|
283
285
|
config.logger = ContextualizedLogs::ContextualizedLogger.new("log/#{Rails.env}.log")
|
|
284
286
|
end
|
|
@@ -286,7 +288,7 @@ end
|
|
|
286
288
|
|
|
287
289
|
### ContextualizedController
|
|
288
290
|
|
|
289
|
-
```
|
|
291
|
+
```ruby
|
|
290
292
|
class Controller < ApplicationController
|
|
291
293
|
include ContextualizedLogs::ContextualizedController
|
|
292
294
|
end
|
|
@@ -296,7 +298,7 @@ end
|
|
|
296
298
|
|
|
297
299
|
### ContextualizedModel
|
|
298
300
|
|
|
299
|
-
```
|
|
301
|
+
```ruby
|
|
300
302
|
class Model < ActiveRecord::Base
|
|
301
303
|
include ContextualizedLogs::ContextualizedModel
|
|
302
304
|
|
|
@@ -305,16 +307,16 @@ class Model < ActiveRecord::Base
|
|
|
305
307
|
end
|
|
306
308
|
```
|
|
307
309
|
|
|
308
|
-
If `ContextualizedLogs::CurrentContext.
|
|
310
|
+
If `ContextualizedLogs::CurrentContext.contextualize_model_enabled` is enable on the current tread, any Model which is created or find will add `{ context_values: { model_ids: ids } }`.
|
|
309
311
|
So if you fetch model (`id == 1`), and create model (`id == 2`), your logs will now contain `{ context_values: { model_ids: [1, 2] } }`.
|
|
310
312
|
|
|
311
313
|
### ContextualizedWorker
|
|
312
314
|
|
|
313
|
-
```
|
|
315
|
+
```ruby
|
|
314
316
|
class Worker
|
|
315
317
|
include ContextualizedLogs::ContextualizedWorker
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
contextualize_worker true # enable logging of job enqueuing, performing, completing and failure
|
|
319
|
+
contextualize_model true # enable logging of any (contextualized) model found or created while performing job
|
|
318
320
|
|
|
319
321
|
# enable adding jobs args (cherry picked) to log metadata (CurrentContext) to be logged alongs any job logs
|
|
320
322
|
def self.contextualize_args(args)
|
|
@@ -323,12 +325,70 @@ class Worker
|
|
|
323
325
|
end
|
|
324
326
|
```
|
|
325
327
|
|
|
326
|
-
If `ContextualizedLogs::CurrentContext.
|
|
328
|
+
If `ContextualizedLogs::CurrentContext.contextualize_model_enabled` is enable on the current tread, any Model which is created or find will add `{ context_values: { model_ids: ids } }`.
|
|
327
329
|
So if you fetch model (`id == 1`), and create model (`id == 2`), your logs will now contain `{ context_values: { model_ids: [1, 2] } }`.
|
|
328
330
|
|
|
329
|
-
|
|
331
|
+
## Configuration
|
|
332
|
+
|
|
333
|
+
`ContextualizedLogs` work with zero configuration by default.
|
|
334
|
+
|
|
335
|
+
It will log:
|
|
336
|
+
- basic request info (`http.request_id`, ....) on each (contextualized) controller
|
|
337
|
+
- basic job info (`enqueued_jobs_ids` on controller which enqueue the job, `job.worker, job.id` on each worker logs, and one log for `enqueuing`, `started`, `processing`, `completing`, [`failure`]) on each (contextualized) worker
|
|
338
|
+
- contextualized models are not logged by default, and needs to be enable on each controller, worker
|
|
330
339
|
|
|
331
|
-
If you wish to logs different predefined metadata (`request.uuid`, `request.ip`, ...)
|
|
340
|
+
If you wish to logs different predefined metadata (`request.uuid`, `request.ip`, ...), or logging mechanism, you can use an initializer `ContextualizedLogs.configure`.
|
|
341
|
+
|
|
342
|
+
```ruby
|
|
343
|
+
# config/initializers/contextualized_logs.rb
|
|
344
|
+
require 'contextualized_logs'
|
|
345
|
+
|
|
346
|
+
module ContextualizedLogs
|
|
347
|
+
configure do |config|
|
|
348
|
+
# enable logging of contextualized model values in all (contextualized) controller by default
|
|
349
|
+
# can be manually enabled on each controller otherwise (contextualize_model true)
|
|
350
|
+
config.controller_default_contextualize_model = true # default: false
|
|
351
|
+
# enable logging of worker enqueing/performing/completing/[failure] in all (contextualized) worker by default
|
|
352
|
+
# can be manually enabled on each worker otherwise (contextualize_worker true)
|
|
353
|
+
config.worker_default_contextualize_worker = true # default: true
|
|
354
|
+
# enable logging of contextualized model values in all (contextualized) worker by default
|
|
355
|
+
# can be manually enabled on each worker otherwise (contextualize_model true)
|
|
356
|
+
config.worker_default_contextualize_model = true # default: false
|
|
357
|
+
# customize logs at Logger level (not in context of a controller request or worker job)
|
|
358
|
+
config.log_formatter = proc do |severity, timestamp, progname, msg|
|
|
359
|
+
# call the default formatter
|
|
360
|
+
log = ContextualizedLogger.default_formatter.call(severity, timestamp, progname, msg)
|
|
361
|
+
# enhance log with Datadog APM trace correlation
|
|
362
|
+
log = JSON.parse(log)
|
|
363
|
+
datadog_correlation = Datadog.tracer.active_correlation
|
|
364
|
+
log.merge!(
|
|
365
|
+
dd: {
|
|
366
|
+
trace_id: datadog_correlation.trace_id,
|
|
367
|
+
span_id: datadog_correlation.span_id
|
|
368
|
+
},
|
|
369
|
+
ddsource: ['ruby']
|
|
370
|
+
)
|
|
371
|
+
# add your own log
|
|
372
|
+
log.merge!(
|
|
373
|
+
my_custom_log_value: 'my_custom_log_value'
|
|
374
|
+
)
|
|
375
|
+
log.to_json + "\n"
|
|
376
|
+
end
|
|
377
|
+
# customize logs extracted from controller (ie: request, ...)
|
|
378
|
+
config.controller_default_contextualizer = proc do |controller|
|
|
379
|
+
# call the default request logging
|
|
380
|
+
ContextualizedController.contextualize_request(controller)
|
|
381
|
+
if controller.current_user
|
|
382
|
+
ContextualizedController.current_context.attributes.merge!(
|
|
383
|
+
usr: {
|
|
384
|
+
id: controller.current_user.id
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
```
|
|
332
392
|
|
|
333
393
|
## Installation
|
|
334
394
|
|
|
@@ -340,7 +400,7 @@ gem 'contextualized_logs'
|
|
|
340
400
|
|
|
341
401
|
And then execute:
|
|
342
402
|
|
|
343
|
-
$ bundle install
|
|
403
|
+
$ bundle install
|
|
344
404
|
|
|
345
405
|
|
|
346
406
|
## Roadmap
|
|
@@ -353,10 +413,8 @@ $ bundle install
|
|
|
353
413
|
|
|
354
414
|
## Specs
|
|
355
415
|
|
|
356
|
-
```
|
|
416
|
+
```shell
|
|
357
417
|
$ rake
|
|
358
|
-
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
|
|
359
|
-
/Users/hugues/.rvm/rubies/ruby-2.5.1/bin/ruby -I/Users/hugues/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.2/lib:/Users/hugues/.rvm/gems/ruby-2.5.1/gems/rspec-support-3.8.3/lib /Users/hugues/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.2/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
|
|
360
418
|
|
|
361
419
|
DummyController
|
|
362
420
|
should set request details
|
|
@@ -382,18 +440,18 @@ ContextualizedLogs::ContextualizedModel
|
|
|
382
440
|
.contextualizable
|
|
383
441
|
set contextualizable keys
|
|
384
442
|
.contextualize
|
|
385
|
-
with
|
|
443
|
+
with contextualize_model_enabled == true
|
|
386
444
|
set contextualizable values
|
|
387
|
-
with
|
|
445
|
+
with contextualize_model_enabled == false
|
|
388
446
|
set contextualizable values
|
|
389
|
-
with CurrentContext.
|
|
447
|
+
with CurrentContext.contextualize_model_enabled == true
|
|
390
448
|
behaves like after_create context
|
|
391
449
|
.after_create
|
|
392
450
|
set context
|
|
393
451
|
behaves like after_find context
|
|
394
452
|
.after_find
|
|
395
453
|
does
|
|
396
|
-
with CurrentContext.
|
|
454
|
+
with CurrentContext.contextualize_model_enabled == false
|
|
397
455
|
behaves like after_create context
|
|
398
456
|
.after_create
|
|
399
457
|
set context
|
|
@@ -424,7 +482,7 @@ ContextualizedLogs::Sidekiq::Middleware::Server::RestoreCurrentContext
|
|
|
424
482
|
behaves like it server yield
|
|
425
483
|
should eq true
|
|
426
484
|
behaves like enable model context values
|
|
427
|
-
|
|
485
|
+
model context values
|
|
428
486
|
with contextualized worker
|
|
429
487
|
behaves like it server yield
|
|
430
488
|
should eq true
|
|
@@ -433,7 +491,7 @@ ContextualizedLogs::Sidekiq::Middleware::Server::RestoreCurrentContext
|
|
|
433
491
|
behaves like log with context
|
|
434
492
|
log with context
|
|
435
493
|
behaves like enable model context values
|
|
436
|
-
|
|
494
|
+
model context values
|
|
437
495
|
with contextualized model worker
|
|
438
496
|
behaves like it server yield
|
|
439
497
|
should eq true
|
|
@@ -442,7 +500,7 @@ ContextualizedLogs::Sidekiq::Middleware::Server::RestoreCurrentContext
|
|
|
442
500
|
behaves like log with context
|
|
443
501
|
log with context
|
|
444
502
|
behaves like enable model context values
|
|
445
|
-
|
|
503
|
+
model context values
|
|
446
504
|
with contextualized model worker
|
|
447
505
|
log with args
|
|
448
506
|
behaves like it server yield
|
|
@@ -452,13 +510,17 @@ ContextualizedLogs::Sidekiq::Middleware::Server::RestoreCurrentContext
|
|
|
452
510
|
behaves like log with context
|
|
453
511
|
log with context
|
|
454
512
|
behaves like enable model context values
|
|
455
|
-
|
|
513
|
+
model context values
|
|
456
514
|
|
|
457
515
|
ContextualizedLogs
|
|
458
516
|
has a version number
|
|
459
517
|
|
|
460
|
-
|
|
461
|
-
|
|
518
|
+
CustomContextController
|
|
519
|
+
should set request details
|
|
520
|
+
should set custom attributes
|
|
521
|
+
|
|
522
|
+
Finished in 1.27 seconds (files took 1.58 seconds to load)
|
|
523
|
+
48 examples, 0 failures
|
|
462
524
|
```
|
|
463
525
|
|
|
464
526
|
## Development
|