nexus_semantic_logger 1.12.9 → 1.12.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/nexus_semantic_logger/version.rb +2 -2
- data/lib/puma/plugin/nexus_puma_statsd.rb +9 -1
- data/lib/rack/response_code_stats_middleware.rb +24 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562ce2a80e027294d0fa28aed717b1328abb49fa273c99c04c86f693e1f6d20f
|
4
|
+
data.tar.gz: a39448a49120379ce921247ba97411fd2200e62189e7a9cacc25ca6c546651dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2501384e077d2d88940b3f22d78acac6ffcc50377a1fb9250498abf099b28fc13a395a7c170da317773ac8a813df24338abd87de7a5f7441b97014553ae0853
|
7
|
+
data.tar.gz: a5690e95153d831570b4b1f4e2ae695b34ab2900c54bf65a2c0abae48a5761bed05f7f8c36717901927e05a477b60c603918b0fba5d7c992e6ee67e641faa7fc
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@ As well as providing a semantic logger, this gem handles datadog telemetry assoc
|
|
10
10
|
* traces
|
11
11
|
* metrics
|
12
12
|
* statsd is automatically attached to datadog runtime metrics and may also be used for custom metrics.
|
13
|
+
* `ResponseCodeStatsMiddleware` is included to capture response code metrics from rack applications
|
13
14
|
|
14
15
|
### Customise log level per logger
|
15
16
|
|
@@ -60,6 +61,13 @@ For example, to increment a count:
|
|
60
61
|
NexusSemanticLogger.metrics.increment('nexus.users.registration.complete')
|
61
62
|
```
|
62
63
|
|
64
|
+
### Rack response code metrics
|
65
|
+
This can be configured with a middleware in application.rb
|
66
|
+
|
67
|
+
```
|
68
|
+
config.middleware.use ResponseCodeStatsMiddleware
|
69
|
+
```
|
70
|
+
|
63
71
|
# Local gem development
|
64
72
|
|
65
73
|
Steps to run this gem from local sources in one the nexus 'staged build' rails components:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module NexusSemanticLogger
|
3
|
-
# Leave this as 1.12.
|
4
|
-
VERSION = '1.12.
|
3
|
+
# Leave this as 1.12.10 in order for CI process to replace with the tagged version.
|
4
|
+
VERSION = '1.12.10'
|
5
5
|
end
|
@@ -163,7 +163,15 @@ Puma::Plugin.create do
|
|
163
163
|
NexusSemanticLogger.metrics.gauge('puma.backlog', stats.backlog, tags: tags)
|
164
164
|
NexusSemanticLogger.metrics.gauge('puma.pool_capacity', stats.pool_capacity, tags: tags)
|
165
165
|
NexusSemanticLogger.metrics.gauge('puma.max_threads', stats.max_threads, tags: tags)
|
166
|
-
NexusSemanticLogger.metrics.
|
166
|
+
NexusSemanticLogger.metrics.increment('puma.requests_count', stats.requests_count, tags: tags)
|
167
|
+
|
168
|
+
ResponseCodeStatsMiddleware.read_and_reset_metrics.each do |code, count|
|
169
|
+
NexusSemanticLogger.metrics.increment(
|
170
|
+
"puma.rack.response.status",
|
171
|
+
count,
|
172
|
+
tags: tags + ["response_status:#{code}"]
|
173
|
+
)
|
174
|
+
end
|
167
175
|
rescue StandardError => e
|
168
176
|
@log_writer.unknown_error(e, nil, '! statsd: notify stats failed')
|
169
177
|
ensure
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# noinspection RubyClassVariableUsageInspection
|
4
|
+
class ResponseCodeStatsMiddleware
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
@@code_metrics = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
status, headers, response = @app.call(env)
|
12
|
+
|
13
|
+
@@code_metrics[status] ||= 0
|
14
|
+
@@code_metrics[status] += 1
|
15
|
+
|
16
|
+
[status, headers, response]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.read_and_reset_metrics
|
20
|
+
metrics = @@code_metrics.dup
|
21
|
+
@@code_metrics.clear
|
22
|
+
metrics
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_semantic_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnathon Harris
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/nexus_semantic_logger/version.rb
|
133
133
|
- lib/puma/plugin/README.md
|
134
134
|
- lib/puma/plugin/nexus_puma_statsd.rb
|
135
|
+
- lib/rack/response_code_stats_middleware.rb
|
135
136
|
- nexus_semantic_logger.gemspec
|
136
137
|
homepage:
|
137
138
|
licenses: []
|