nexus_semantic_logger 1.8.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nexus_semantic_logger/application.rb +2 -0
- data/lib/nexus_semantic_logger/datadog_singleton.rb +15 -5
- data/lib/nexus_semantic_logger/extensions/action_dispatch/debug_exceptions.rb +2 -1
- data/lib/nexus_semantic_logger/logger_metrics_subscriber.rb +35 -0
- data/lib/nexus_semantic_logger/version.rb +2 -2
- data/lib/nexus_semantic_logger.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57a5a486139a60e0e5de042138019b44dcd7535ed1efbd7dabfae3675e642b9
|
4
|
+
data.tar.gz: 982141f8ee6a724cc1d276ab9919951d5ed528277da596074ddc105e6fec4fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d8a2f40cbdfcf5122765a2d0009ad2438fe0fce64a30fa08584e728e5d4f8867e418cd047f2a8c24ac3f9531468bfe8cac96ccb1317e2f95d7fddf23cdaf3f
|
7
|
+
data.tar.gz: 426ae82619142b34e2e5e3ad425ac77d6f0eb944a70f3fd814d8d5cfdba9df8f083785a53e85fbb1127dea3a5e093e56f8449ca089fbb142c32bdee09ba2cb6d
|
@@ -39,6 +39,8 @@ module NexusSemanticLogger
|
|
39
39
|
|
40
40
|
NexusSemanticLogger::DatadogTracer.new(service)
|
41
41
|
|
42
|
+
SemanticLogger.on_log(NexusSemanticLogger::LoggerMetricsSubscriber.new)
|
43
|
+
|
42
44
|
logger.info('SemanticLogger initialised.', level: config.log_level)
|
43
45
|
|
44
46
|
config.after_initialize do
|
@@ -17,7 +17,7 @@ module NexusSemanticLogger
|
|
17
17
|
# @param [String] metric Metric name.
|
18
18
|
# @param [Array<String>] tags Additional tags.
|
19
19
|
def increment(metric, tags: [])
|
20
|
-
statsd&.increment(metric, tags:
|
20
|
+
statsd&.increment(metric, tags: combine_tags(tags))
|
21
21
|
flush
|
22
22
|
end
|
23
23
|
|
@@ -25,7 +25,7 @@ module NexusSemanticLogger
|
|
25
25
|
# @param [String] metric Metric name.
|
26
26
|
# @param [Array<String>] tags Additional tags.
|
27
27
|
def decrement(metric, tags: [])
|
28
|
-
statsd&.decrement(metric, tags:
|
28
|
+
statsd&.decrement(metric, tags: combine_tags(tags))
|
29
29
|
flush
|
30
30
|
end
|
31
31
|
|
@@ -34,7 +34,7 @@ module NexusSemanticLogger
|
|
34
34
|
# @param [Integer] ms Timing in milliseconds.
|
35
35
|
# @param [Array<String>] tags Additional tags.
|
36
36
|
def timing(metric, ms, tags: [])
|
37
|
-
statsd&.timing(metric, ms, tags:
|
37
|
+
statsd&.timing(metric, ms, tags: combine_tags(tags))
|
38
38
|
flush
|
39
39
|
end
|
40
40
|
|
@@ -43,7 +43,7 @@ module NexusSemanticLogger
|
|
43
43
|
# @param [Numeric] value Distribution value.
|
44
44
|
# @param [Array<String>] tags Additional tags.
|
45
45
|
def distribution(metric, value, tags: [])
|
46
|
-
statsd&.distribution(metric, value, tags:
|
46
|
+
statsd&.distribution(metric, value, tags: combine_tags(tags))
|
47
47
|
flush
|
48
48
|
end
|
49
49
|
|
@@ -52,8 +52,18 @@ module NexusSemanticLogger
|
|
52
52
|
# @param [Numeric] value Gauge value.
|
53
53
|
# @param [Array<String>] tags Additional tags.
|
54
54
|
def gauge(metric, value, tags: [])
|
55
|
-
statsd&.gauge(metric, value, tags:
|
55
|
+
statsd&.gauge(metric, value, tags: combine_tags(tags))
|
56
56
|
flush
|
57
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# Safely combine the global tags with the supplied tags.
|
62
|
+
def combine_tags(tags)
|
63
|
+
final_tags = []
|
64
|
+
final_tags += global_tags unless global_tags.nil?
|
65
|
+
final_tags += tags unless tags.nil?
|
66
|
+
final_tags
|
67
|
+
end
|
58
68
|
end
|
59
69
|
end
|
@@ -11,7 +11,8 @@ module ActionDispatch
|
|
11
11
|
undef_method :log_error
|
12
12
|
|
13
13
|
def log_error(request, wrapper)
|
14
|
-
|
14
|
+
# log_rescued_responses? is a rails7 feature, but this gem is also used on rails6. Check for its existence.
|
15
|
+
return if respond_to?('log_rescued_responses?') && !log_rescued_responses?(request) && wrapper.rescue_response?
|
15
16
|
|
16
17
|
ActiveSupport::Deprecation.silence do
|
17
18
|
ActionController::Base.logger.fatal(wrapper.exception)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'semantic_logger'
|
3
|
+
|
4
|
+
module NexusSemanticLogger
|
5
|
+
# Sends SemanticLogger metrics to statsd.
|
6
|
+
# See https://logger.rocketjob.io/metrics.html
|
7
|
+
# Based on https://github.com/reidmorrison/semantic_logger/blob/master/lib/semantic_logger/metric/statsd.rb
|
8
|
+
class LoggerMetricsSubscriber < SemanticLogger::Subscriber
|
9
|
+
def call(log)
|
10
|
+
log(log) if should_log?(log)
|
11
|
+
end
|
12
|
+
|
13
|
+
def log(log)
|
14
|
+
metric = log.metric
|
15
|
+
tags = log.payload.nil? ? nil : []
|
16
|
+
log.payload&.each_pair { |key, value| tags << "#{key}:#{value}" }
|
17
|
+
if (duration = log.duration)
|
18
|
+
NexusSemanticLogger.metrics.timing(metric, duration, tags: tags)
|
19
|
+
else
|
20
|
+
amount = (log.metric_amount || 1).round
|
21
|
+
if amount.negative?
|
22
|
+
NexusSemanticLogger.metrics.decrement(metric, tags: tags)
|
23
|
+
else
|
24
|
+
NexusSemanticLogger.metrics.increment(metric, tags: tags)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Only forward log entries that contain metrics.
|
30
|
+
def should_log?(log)
|
31
|
+
# Does not support metrics with dimensions.
|
32
|
+
log.metric && !log.dimensions && meets_log_level?(log) && !filtered?(log)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module NexusSemanticLogger
|
3
|
-
# Leave this as 1.
|
4
|
-
VERSION = '1.
|
3
|
+
# Leave this as 1.10.0 in order for CI process to replace with the tagged version.
|
4
|
+
VERSION = '1.10.0'
|
5
5
|
end
|
@@ -4,6 +4,7 @@ require 'nexus_semantic_logger/application'
|
|
4
4
|
require 'nexus_semantic_logger/datadog_formatter'
|
5
5
|
require 'nexus_semantic_logger/datadog_singleton'
|
6
6
|
require 'nexus_semantic_logger/datadog_tracer'
|
7
|
+
require 'nexus_semantic_logger/logger_metrics_subscriber'
|
7
8
|
|
8
9
|
module NexusSemanticLogger
|
9
10
|
# Get application wide object for sending metrics.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_semantic_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnathon Harris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/nexus_semantic_logger/datadog_singleton.rb
|
113
113
|
- lib/nexus_semantic_logger/datadog_tracer.rb
|
114
114
|
- lib/nexus_semantic_logger/extensions/action_dispatch/debug_exceptions.rb
|
115
|
+
- lib/nexus_semantic_logger/logger_metrics_subscriber.rb
|
115
116
|
- lib/nexus_semantic_logger/sneakers_metrics.rb
|
116
117
|
- lib/nexus_semantic_logger/version.rb
|
117
118
|
- nexus_semantic_logger.gemspec
|
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
134
|
- !ruby/object:Gem::Version
|
134
135
|
version: '0'
|
135
136
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.4.6
|
137
138
|
signing_key:
|
138
139
|
specification_version: 4
|
139
140
|
summary: semantic_logger usage for nexus
|