metrics_adapter 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/metrics_adapter/adapters/mixpanel.rb +1 -1
- data/lib/metrics_adapter/rails.rb +2 -7
- data/lib/metrics_adapter/trackers/base.rb +2 -0
- data/lib/metrics_adapter/trackers/slow_request.rb +5 -0
- data/lib/metrics_adapter/version.rb +1 -1
- data/metrics_adapter.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d1968699aa29c1905c1c244a71b9099a16cfccb66e9395ffa8c59b1332440d
|
4
|
+
data.tar.gz: 7f96f6eb51f45b679a845d1d42fd25d2fa1ca7672f3427b256d952bcf8e3a7bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 705ae7487d7d3ba8969fa0f06f34d32849b1b897d912c5083f7ba37d2dc64a595e93fe98e28e6d0abcdad5dd30cc9fba0b656f785f0355337e839fbc53c6143c
|
7
|
+
data.tar.gz: a650442ffb4ff0bac4307b502a785c98b3addb38069f70888fac2ef2fcb0884f363cae0b489a0a5b06d089823f65fcccdd66326863043783ff4caba28a61328c
|
data/README.md
CHANGED
@@ -60,6 +60,8 @@ Below we setup the Keen service using the slow request tracker:
|
|
60
60
|
config.extra_attributes = { app: 'My-App' }
|
61
61
|
config.logger = Rails.logger
|
62
62
|
config.trackers = %i(slow_request)
|
63
|
+
block = -> { ENV['SOME_ENVIRONMENT_VARIABLE'] == 'production' }
|
64
|
+
config.conditionals = { slow_request: block }
|
63
65
|
config.thresholds = { slow_request: 1_000 }
|
64
66
|
end
|
65
67
|
```
|
@@ -2,12 +2,7 @@
|
|
2
2
|
## 1. Tracks slow request given a threshold
|
3
3
|
##
|
4
4
|
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |event|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
if conditional.present? && conditional.call.blank?
|
9
|
-
Rails.logger.info('Metrics Adapter wont publish slow request metric.')
|
10
|
-
else
|
11
|
-
MetricsAdapter::Trackers::SlowRequest.new(event).call if trackers.include?(:slow_request)
|
5
|
+
if MetricsAdapter.trackers.include?(:slow_request)
|
6
|
+
MetricsAdapter::Trackers::SlowRequest.new(event).call
|
12
7
|
end
|
13
8
|
end
|
@@ -2,6 +2,7 @@ module MetricsAdapter
|
|
2
2
|
module Trackers
|
3
3
|
class Base
|
4
4
|
attr_reader :adapter,
|
5
|
+
:conditional,
|
5
6
|
:event,
|
6
7
|
:extra_attributes,
|
7
8
|
:logger,
|
@@ -16,6 +17,7 @@ module MetricsAdapter
|
|
16
17
|
@extra_attributes = ::MetricsAdapter.extra_attributes
|
17
18
|
@logger = ::MetricsAdapter.logger
|
18
19
|
@metric_name = self.class.name.demodulize.underscore
|
20
|
+
@conditional = ::MetricsAdapter.conditionals[@metric_name.to_sym]
|
19
21
|
end
|
20
22
|
|
21
23
|
def call
|
@@ -9,6 +9,8 @@ module MetricsAdapter
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call
|
12
|
+
return if conditional.present? && conditional.call.blank?
|
13
|
+
|
12
14
|
if event.duration > slow_request_threshold
|
13
15
|
data = {
|
14
16
|
id: event.transaction_id,
|
@@ -19,6 +21,9 @@ module MetricsAdapter
|
|
19
21
|
idle_time_in_ms: event.idle_time,
|
20
22
|
path: event.payload[:path]
|
21
23
|
}.merge(extra_attributes)
|
24
|
+
logger.info(
|
25
|
+
"Slow request detected. Sending data to #{adapter.class.name}"
|
26
|
+
) if logger
|
22
27
|
adapter.publish(data)
|
23
28
|
end
|
24
29
|
end
|
data/metrics_adapter.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metrics_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Form builder developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Collect custom metrics from your application.
|
98
112
|
email:
|
99
113
|
- form-builder-team@digital.justice.gov.uk
|