opinionated-metrics 0.0.1
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 +7 -0
- data/lib/metrics_service.rb +40 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b08ee7c64cb1abc2dab9955b2b9c332d0190a95a
|
|
4
|
+
data.tar.gz: 96dcbb663818cf6bee2e2e47755d6b87e8742a04
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9884de9dafeb75a9249953c53e43013b0cd35edf4c78c025161e7e80b3c5840d8240a89433136402e8d631b1a0966b2f9f34555268ecac3fecb58d1fc9a6fd3a
|
|
7
|
+
data.tar.gz: da0514afbb1ae142495169eb6abcbd00d72e79758d00439076e7d4aeab842273a539a29b3811fd2893701f8929c773e604b291b19eae6a54979c7128966d7db3
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class MetricsService
|
|
2
|
+
def self.event(name, **additional_properties)
|
|
3
|
+
properties = {name: name}.merge(additional_properties)
|
|
4
|
+
::NewRelic::Agent.record_custom_event("TrackedEvent", properties)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.time_operation(name, **additional_properties)
|
|
8
|
+
raise 'A block is required for time_operation calls' unless block_given?
|
|
9
|
+
|
|
10
|
+
start = Time.current
|
|
11
|
+
yield
|
|
12
|
+
duration_start_end(name, start, Time.current, **additional_properties)
|
|
13
|
+
rescue StandardError => e
|
|
14
|
+
Rails.logger.error("Failed reporting timing to NewRelic: #{e}")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.duration_start_end(name, start, finish, **additional_properties)
|
|
18
|
+
duration(name, (finish - start).seconds, **additional_properties)
|
|
19
|
+
rescue StandardError => e
|
|
20
|
+
Rails.logger.error("Failed reporting duration to NewRelic: #{e}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.duration(name, duration, **additional_properties)
|
|
24
|
+
properties = {name: name, duration: duration.in_milliseconds}.merge(additional_properties)
|
|
25
|
+
::NewRelic::Agent.record_custom_event("OpDurationMs", properties)
|
|
26
|
+
rescue StandardError => e
|
|
27
|
+
Rails.logger.error("Failed reporting duration to NewRelic: #{e}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.exception(name, exception)
|
|
31
|
+
error(name, type: exception.class.name, message: exception&.message)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.error(name, **additional_properties)
|
|
35
|
+
properties = {error_name: name}.merge(additional_properties)
|
|
36
|
+
::NewRelic::Agent.record_custom_event("Error", properties)
|
|
37
|
+
rescue StandardError => e
|
|
38
|
+
Rails.logger.error("Failed reporting error to NewRelic: #{e}")
|
|
39
|
+
end
|
|
40
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: opinionated-metrics
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Brian Wyant
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Simple metrics gem built to abstract out metrics provider differences
|
|
14
|
+
email: bwyant@helloinspire.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/metrics_service.rb
|
|
20
|
+
homepage: http://rubygems.org/gems/opinionated-metrics
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.6.14.3
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Simple metrics gem built to abstract out metrics provider differences
|
|
44
|
+
test_files: []
|