sapience 2.3.5 → 2.4.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/sapience/error_handler/sentry.rb +3 -2
- data/lib/sapience/metrics/datadog.rb +29 -0
- data/lib/sapience/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242e44a2d89e27ec8aa394c77164599aaea34da7
|
4
|
+
data.tar.gz: dc875d0fd20dc77d838e67e7d7e1052efae3102f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae00691b82ab10345121193832cb0a2f9616d7a78ac86abfae1b1982c8a3d7474f44960b8e5d114b61c4fe3d48df18112c3ab6dd7bf02f642161023862f19b84
|
7
|
+
data.tar.gz: bb38d039a741e6f92371735fafa2f29cdade79aa43c755c8137c0b2d08d60f3db51fc9fb5eee5acd2c30380f9a01ef629b555cea54285192afa67f92be99ce9d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v2.4.0
|
2
|
+
|
3
|
+
- Add shortcut metrics
|
4
|
+
- `Sapience.metrics.success(module_name<string>, action<string>, opts<hash>)`
|
5
|
+
- `Sapience.metrics.error(module_name<string>, action<string>, opts<hash>)`
|
6
|
+
- `Sapience.metrics.exception(module_name<string>, action<string>, opts<hash>)`
|
7
|
+
|
1
8
|
## v2.3.5
|
2
9
|
|
3
10
|
- Set Sapience.config.app_name when APP_NAME environment variable is set
|
@@ -23,8 +23,9 @@ module Sapience
|
|
23
23
|
# dsn: [String]
|
24
24
|
# Url to configure Sentry-Raven.
|
25
25
|
# Default: nil
|
26
|
-
def initialize(
|
27
|
-
fail ArgumentError, "Options should be a Hash" unless
|
26
|
+
def initialize(opts = {})
|
27
|
+
fail ArgumentError, "Options should be a Hash" unless opts.is_a?(Hash)
|
28
|
+
options = opts.dup
|
28
29
|
|
29
30
|
options[:level] ||= :error
|
30
31
|
@sentry_logger_level = options[:level]
|
@@ -135,6 +135,18 @@ module Sapience
|
|
135
135
|
provider.event(title, text, opts)
|
136
136
|
end
|
137
137
|
|
138
|
+
def success(module_name, action, opts = {})
|
139
|
+
increment("success", add_tags(module_name, action, opts))
|
140
|
+
end
|
141
|
+
|
142
|
+
def error(module_name, action, opts = {})
|
143
|
+
increment("error", add_tags(module_name, action, opts))
|
144
|
+
end
|
145
|
+
|
146
|
+
def exception(module_name, action, opts = {})
|
147
|
+
increment("exception", add_tags(module_name, action, opts))
|
148
|
+
end
|
149
|
+
|
138
150
|
def namespace
|
139
151
|
ns = Sapience.namify(Sapience.app_name)
|
140
152
|
ns << ".#{Sapience.namify(Sapience.environment)}" if Sapience.environment
|
@@ -147,6 +159,23 @@ module Sapience
|
|
147
159
|
tags: @tags,
|
148
160
|
}
|
149
161
|
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def add_tags(module_name, action, opts)
|
166
|
+
tags = opts.fetch(:tags, [])
|
167
|
+
clean_up_tags(tags, :module, module_name)
|
168
|
+
clean_up_tags(tags, :action, action)
|
169
|
+
tags << "module:#{module_name}" << "action:#{action}"
|
170
|
+
opts[:tags] = tags
|
171
|
+
opts
|
172
|
+
end
|
173
|
+
|
174
|
+
def clean_up_tags(tags, key, value)
|
175
|
+
old_tags = tags.dup
|
176
|
+
tags.delete_if { |a| a =~ /^#{key}:/ }
|
177
|
+
::Sapience.logger.warn("WARNING: tag '#{key}' already exist, overwritten with #{value}") if tags != old_tags
|
178
|
+
end
|
150
179
|
end
|
151
180
|
end
|
152
181
|
end
|
data/lib/sapience/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|