sapience 2.0.5 → 2.1.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 +5 -0
- data/docs/metrics.md +47 -11
- data/lib/sapience/error_handler/sentry.rb +45 -3
- data/lib/sapience/version.rb +1 -1
- data/sapience.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7af7111709b92aaa1a65d94c9f8033c75bec80ad
|
4
|
+
data.tar.gz: 5de17972d7e7c4c6dd0ff51501df9a67a417df8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa1e5cffa6779704c9521b987ad85499d728537162f2eb4a7fa098436380929ee5c56fa392d660447001c0008856decbf30778c745b2dc4d9d36cb667a663776
|
7
|
+
data.tar.gz: 47c9b58310c9777e2746138c4037b4ee1f42cb52e49f8910028b526ee166a9940d42d1137240bfe8a469593d39364961fb0c1d9965ab6ec3c00d03503acd5f04
|
data/CHANGELOG.md
CHANGED
data/docs/metrics.md
CHANGED
@@ -9,7 +9,7 @@ You can configure datadog through "sapience.yml", using the "metrics" section sh
|
|
9
9
|
```yml
|
10
10
|
production:
|
11
11
|
log_level: info
|
12
|
-
|
12
|
+
|
13
13
|
metrics:
|
14
14
|
datadog:
|
15
15
|
url: <%= ENV.fetch("STATSD_URL", "udp://localhost:8125") %>
|
@@ -22,7 +22,7 @@ Sapience.metrics = { datadog: { url: ENV["STATSD_URL"] } }
|
|
22
22
|
|
23
23
|
Of course, whatever url you use (like for example "udp://localhost:8125"), make sure you have launched the Datadog agent listening to that host and url. See how to install a Datadog agent in the [Datadog Agent Documentation](http://docs.datadoghq.com/guides/basic_agent_usage/).
|
24
24
|
|
25
|
-
Then you can send
|
25
|
+
Then you can send metrics to Datadog using the following methods:
|
26
26
|
```ruby
|
27
27
|
timing(metric, duration = 0, options = {})
|
28
28
|
increment(metric, options = {})
|
@@ -38,14 +38,50 @@ event(title, text, options = {})
|
|
38
38
|
As in the examples below:
|
39
39
|
```ruby
|
40
40
|
metrics = Sapience.metrics
|
41
|
-
metrics.timing("
|
42
|
-
metrics.increment("
|
43
|
-
metrics.decrement("
|
44
|
-
metrics.
|
45
|
-
metrics.
|
46
|
-
metrics.
|
41
|
+
metrics.timing("metric-key", 100)
|
42
|
+
metrics.increment("metric-key")
|
43
|
+
metrics.decrement("metric-key")
|
44
|
+
metrics.count("metric-key", -3)
|
45
|
+
metrics.histogram("metric-key", 2_500)
|
46
|
+
metrics.gauge("metric-key", 1_000, {})
|
47
|
+
metrics.event("metric-key", "description about event", {})
|
47
48
|
metrics.batch do
|
48
|
-
metrics.event("
|
49
|
-
metrics.increment("
|
49
|
+
metrics.event("metric-key", "description about event", {})
|
50
|
+
metrics.increment("another-metric-key", 2)
|
50
51
|
end
|
51
|
-
```
|
52
|
+
```
|
53
|
+
|
54
|
+
### Metric keys and tags
|
55
|
+
|
56
|
+
The metric key argument used in all tracking methods can be arbitrary string however we recommend to use combination of names
|
57
|
+
identifying component of your system joined by dots. All the metric keys are automatically prefixed with `app_name.environment`.
|
58
|
+
|
59
|
+
We use two different schema for key that can be combined in one app:
|
60
|
+
|
61
|
+
#### Fully specified key
|
62
|
+
|
63
|
+
```
|
64
|
+
app_name.environment.module.(component)*.event
|
65
|
+
```
|
66
|
+
|
67
|
+
The key fully identify the source of event and is useful in cases where you don't need to aggregate events
|
68
|
+
occurred in one component, module or whole app. Example:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
metrics.increment('authentication.sign_in') # full key: booking_app.production.authentication.sign_in
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Partially specified key in combination with tags
|
75
|
+
|
76
|
+
```
|
77
|
+
key: app_name.environment.event_type
|
78
|
+
tags: event:name, module:name, component:name
|
79
|
+
```
|
80
|
+
|
81
|
+
The key itself doesn't identify the source of tracked event and is useful in cases where you want to aggregate events
|
82
|
+
occurred in one component, module or whole app. It's handy for event types that can occur in all modules of an app.
|
83
|
+
We use it mainly for error metrics. Example:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
metrics.increment('error', tags: %w(error_class:AccessDenied module:authentication component:permissions))
|
87
|
+
```
|
@@ -37,13 +37,22 @@ module Sapience
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def capture_exception(exception, payload = {})
|
40
|
-
|
40
|
+
capture_type(exception, payload)
|
41
41
|
end
|
42
42
|
|
43
43
|
def capture_message(message, payload = {})
|
44
|
-
|
44
|
+
capture_type(message, payload)
|
45
45
|
end
|
46
46
|
|
47
|
+
def user_context(options = {})
|
48
|
+
Raven.user_context(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def tags_context(options = {})
|
52
|
+
Raven.tags_context(options)
|
53
|
+
end
|
54
|
+
alias_method :tags=, :tags_context
|
55
|
+
|
47
56
|
def configured?
|
48
57
|
@configured == true
|
49
58
|
end
|
@@ -58,9 +67,42 @@ module Sapience
|
|
58
67
|
@configured = true
|
59
68
|
end
|
60
69
|
|
70
|
+
# Capture, process and reraise any exceptions from the given block.
|
71
|
+
#
|
72
|
+
# @example
|
73
|
+
# Raven.capture do
|
74
|
+
# MyApp.run
|
75
|
+
# end
|
76
|
+
def capture!(options = {})
|
77
|
+
fail ArgumentError unless block_given?
|
78
|
+
|
79
|
+
begin
|
80
|
+
yield
|
81
|
+
rescue StandardError => e
|
82
|
+
capture_type(e, options)
|
83
|
+
raise
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Capture, process and not reraise any exceptions from the given block.
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# Raven.capture do
|
91
|
+
# MyApp.run
|
92
|
+
# end
|
93
|
+
def capture(options = {})
|
94
|
+
fail ArgumentError unless block_given?
|
95
|
+
|
96
|
+
begin
|
97
|
+
yield
|
98
|
+
rescue StandardError => e
|
99
|
+
capture_type(e, options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
61
103
|
private
|
62
104
|
|
63
|
-
def
|
105
|
+
def capture_type(data, payload)
|
64
106
|
return false unless valid?
|
65
107
|
configure_sentry
|
66
108
|
|
data/lib/sapience/version.rb
CHANGED
data/sapience.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "Hasslefree autoconfiguration for logging, metrics and exception collection."
|
13
13
|
spec.description = "Hasslefree autoconfiguration for logging, metrics and exception collection."
|
14
|
-
spec.homepage = "https://github.com/reevoo/sapience"
|
14
|
+
spec.homepage = "https://github.com/reevoo/sapience-rb"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
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.0
|
4
|
+
version: 2.1.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-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -365,7 +365,7 @@ files:
|
|
365
365
|
- lib/sapience/version.rb
|
366
366
|
- lib/tasks/coverage.rake
|
367
367
|
- sapience.gemspec
|
368
|
-
homepage: https://github.com/reevoo/sapience
|
368
|
+
homepage: https://github.com/reevoo/sapience-rb
|
369
369
|
licenses:
|
370
370
|
- MIT
|
371
371
|
metadata:
|