salestation 5.3.3 → 5.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e67e18c608d03d9fa6f1e3cff2345dd87eb55f76d7e087e57a75c4ce2b6f591f
4
- data.tar.gz: '086a420e0dcd1483b346253be2d3a18405f02ee310956ae69501dd47832a1800'
3
+ metadata.gz: bd7b52225452bf9e306427aac8619e9b4a41a7b2301fd050e5cadef33ce0a609
4
+ data.tar.gz: 919ed91a19ac79a75bb09d6b786c885b201b46c719b0bd2bb59b8e132629fca8
5
5
  SHA512:
6
- metadata.gz: 0fc035f130d5e795c15facde88ab5b2961a188e6c33bd40fa742f8b7700996c6b6a2dabc637b4a9083b4c364e9ed37ba97aca977231051a3410d91adb6fd4657
7
- data.tar.gz: 4a1e69e9fd30f9c6c1e7d46853849f5db4614c684051ae38c39af0075fad267ad5ecba456c559866bb032f909bbf95bbe838ada29390c6a8b062f881758d8747
6
+ metadata.gz: 38c10c460642865693c5941430ac49cfc97b5d17296ac434ab5d1f43ac7f79a7b98f7da39f310b31fd099056d8104f6c3816e73bff727e596e75081c1b1fee40
7
+ data.tar.gz: 05046b1499641bb9c889a0d97ef68cb7d8d650089f2f8b317a0e96108819a436e8883768973ed437b736a4c273abadd0e58e5308cc5d31ce7dbdf3da2905c824
data/README.md CHANGED
@@ -167,6 +167,15 @@ class Webapp < Sinatra::Base
167
167
  end
168
168
  ```
169
169
 
170
+ You can configure per-request fields by defining `salestation.request_logger.fields` in sinatra `env`:
171
+
172
+ ```ruby
173
+ def my_handler(env)
174
+ env['salestation.request_logger.fields'] = { foo: 'bar' }
175
+ # ...
176
+ end
177
+ ```
178
+
170
179
  ### Using StatsD
171
180
 
172
181
  Salestation provides a StatsD middleware which can be used record request
@@ -3,6 +3,8 @@
3
3
  module Salestation
4
4
  class Web < Module
5
5
  class RequestLogger
6
+ EXTRA_FIELDS_ENV_KEY = 'salestation.request_logger.fields'
7
+
6
8
  DURATION_PRECISION = 6
7
9
  REMOTE_ADDR = 'REMOTE_ADDR'
8
10
  REQUEST_URI = 'REQUEST_URI'
@@ -13,6 +15,8 @@ module Salestation
13
15
  HTTP_ACCEPT = 'HTTP_ACCEPT'
14
16
  HTTP_ORIGIN = 'HTTP_ORIGIN'
15
17
  SERVER_NAME = 'SERVER_NAME'
18
+ GLIA_ACCOUNT_ID = 'HTTP_GLIA_ACCOUNT_ID'
19
+ GLIA_USER_ID = 'HTTP_GLIA_USER_ID'
16
20
 
17
21
  def initialize(app, logger, log_response_body: false, level: :info)
18
22
  @app = app
@@ -47,18 +51,20 @@ module Salestation
47
51
 
48
52
  def response_log(env, status, headers, body, began_at)
49
53
  log = {
50
- remote_addr: env[REMOTE_ADDR],
51
- method: env[REQUEST_METHOD],
52
- path: env[REQUEST_URI],
53
- query: env[QUERY_STRING],
54
- content_type: env[CONTENT_TYPE],
55
- http_agent: env[HTTP_USER_AGENT],
56
- http_accept: env[HTTP_ACCEPT],
57
- http_origin: env[HTTP_ORIGIN],
58
- server_name: env[SERVER_NAME],
59
- status: status,
60
- duration: duration(from: began_at),
61
- headers: headers
54
+ remote_addr: env[REMOTE_ADDR],
55
+ method: env[REQUEST_METHOD],
56
+ path: env[REQUEST_URI],
57
+ query: env[QUERY_STRING],
58
+ content_type: env[CONTENT_TYPE],
59
+ http_agent: env[HTTP_USER_AGENT],
60
+ http_accept: env[HTTP_ACCEPT],
61
+ http_origin: env[HTTP_ORIGIN],
62
+ server_name: env[SERVER_NAME],
63
+ status: status,
64
+ duration: duration(from: began_at),
65
+ glia_account_id: env[GLIA_ACCOUNT_ID],
66
+ glia_user_id: env[GLIA_USER_ID],
67
+ headers: headers
62
68
  }
63
69
 
64
70
  if status >= 400
@@ -67,7 +73,8 @@ module Salestation
67
73
  log[:body] = body.join
68
74
  end
69
75
 
70
- log
76
+ extra_fields = env.fetch(EXTRA_FIELDS_ENV_KEY, {})
77
+ log.merge!(extra_fields)
71
78
  end
72
79
 
73
80
  def duration(from:)
data/salestation.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "salestation"
7
- spec.version = "5.3.3"
7
+ spec.version = "5.5.0"
8
8
  spec.authors = ["Glia TechMovers"]
9
9
  spec.email = ["open-source@glia.com"]
10
10
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salestation
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.3
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-12-27 00:00:00.000000000 Z
10
+ date: 2025-02-18 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -220,7 +219,6 @@ homepage: ''
220
219
  licenses:
221
220
  - MIT
222
221
  metadata: {}
223
- post_install_message:
224
222
  rdoc_options: []
225
223
  require_paths:
226
224
  - lib
@@ -235,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
233
  - !ruby/object:Gem::Version
236
234
  version: '0'
237
235
  requirements: []
238
- rubygems_version: 3.5.3
239
- signing_key:
236
+ rubygems_version: 3.6.2
240
237
  specification_version: 4
241
238
  summary: ''
242
239
  test_files: []