nexus_semantic_logger 1.12.10 → 1.12.11

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: 562ce2a80e027294d0fa28aed717b1328abb49fa273c99c04c86f693e1f6d20f
4
- data.tar.gz: a39448a49120379ce921247ba97411fd2200e62189e7a9cacc25ca6c546651dc
3
+ metadata.gz: a159e8a863f9c0b2e1d650c8616b1de85eeedc314acb27326409bf2fefdd8492
4
+ data.tar.gz: 8cd3b01ad9051d3124833b240c525e9b357372c30301e14b0c8ce97ece199848
5
5
  SHA512:
6
- metadata.gz: a2501384e077d2d88940b3f22d78acac6ffcc50377a1fb9250498abf099b28fc13a395a7c170da317773ac8a813df24338abd87de7a5f7441b97014553ae0853
7
- data.tar.gz: a5690e95153d831570b4b1f4e2ae695b34ab2900c54bf65a2c0abae48a5761bed05f7f8c36717901927e05a477b60c603918b0fba5d7c992e6ee67e641faa7fc
6
+ metadata.gz: eb863e5805b8010dd8f0fc6169f85657b7e4a735e26bd2080ff78d3029a1f633d6a9d69484743f7b7225e9fdf0006aaffe12bcebc70617be85956155033193f8
7
+ data.tar.gz: a7ff2cdb97f46b86206d54e029eaebc10ee4ae775a5ca6e25c73fd8cc7f8b919cda21c4b257da5b245eed9625c98474075372b01993c812e35bf342809cd83a9
@@ -56,6 +56,15 @@ module NexusSemanticLogger
56
56
  flush
57
57
  end
58
58
 
59
+ # Delegate to statsd (if available).
60
+ # @param [String] metric Metric name.
61
+ # @param [Numeric] value Count value.
62
+ # @param [Array<String>] tags Additional tags.
63
+ def count(metric, value, tags: [])
64
+ statsd&.count(metric, value, tags: combine_tags(tags))
65
+ flush
66
+ end
67
+
59
68
  private
60
69
 
61
70
  # Safely combine the supplied tags.
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # noinspection RubyClassVariableUsageInspection
4
+ module NexusSemanticLogger
5
+ class ResponseCodeStatsMiddleware
6
+ def initialize(app)
7
+ @app = app
8
+ @@code_metrics = {}
9
+ end
10
+
11
+ def call(env)
12
+ status, headers, response = @app.call(env)
13
+
14
+ @@code_metrics[status] ||= 0
15
+ @@code_metrics[status] += 1
16
+
17
+ [status, headers, response]
18
+ end
19
+
20
+ def self.read_and_reset_metrics
21
+ metrics = @@code_metrics.dup
22
+ @@code_metrics.clear
23
+ metrics
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module NexusSemanticLogger
3
- # Leave this as 1.12.10 in order for CI process to replace with the tagged version.
4
- VERSION = '1.12.10'
3
+ # Leave this as 1.12.11 in order for CI process to replace with the tagged version.
4
+ VERSION = '1.12.11'
5
5
  end
@@ -6,6 +6,7 @@ require 'nexus_semantic_logger/datadog_singleton'
6
6
  require 'nexus_semantic_logger/datadog_tracer'
7
7
  require 'nexus_semantic_logger/ddtrace_ruby3_patch'
8
8
  require 'nexus_semantic_logger/logger_metrics_subscriber'
9
+ require 'nexus_semantic_logger/response_code_stats_middleware'
9
10
 
10
11
  module NexusSemanticLogger
11
12
  # Get application wide object for sending metrics.
@@ -163,10 +163,10 @@ 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.increment('puma.requests_count', stats.requests_count, tags: tags)
166
+ NexusSemanticLogger.metrics.count('puma.requests_count', stats.requests_count, tags: tags)
167
167
 
168
- ResponseCodeStatsMiddleware.read_and_reset_metrics.each do |code, count|
169
- NexusSemanticLogger.metrics.increment(
168
+ NexusSemanticLogger::ResponseCodeStatsMiddleware.read_and_reset_metrics.each do |code, count|
169
+ NexusSemanticLogger.metrics.count(
170
170
  "puma.rack.response.status",
171
171
  count,
172
172
  tags: tags + ["response_status:#{code}"]
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.10
4
+ version: 1.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnathon Harris
@@ -128,11 +128,11 @@ files:
128
128
  - lib/nexus_semantic_logger/ddtrace_ruby3_patch.rb
129
129
  - lib/nexus_semantic_logger/extensions/action_dispatch/debug_exceptions.rb
130
130
  - lib/nexus_semantic_logger/logger_metrics_subscriber.rb
131
+ - lib/nexus_semantic_logger/response_code_stats_middleware.rb
131
132
  - lib/nexus_semantic_logger/sneakers_metrics.rb
132
133
  - lib/nexus_semantic_logger/version.rb
133
134
  - lib/puma/plugin/README.md
134
135
  - lib/puma/plugin/nexus_puma_statsd.rb
135
- - lib/rack/response_code_stats_middleware.rb
136
136
  - nexus_semantic_logger.gemspec
137
137
  homepage:
138
138
  licenses: []
@@ -1,24 +0,0 @@
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