sapience 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -8
- data/README.md +12 -12
- data/lib/sapience/extensions/notifications.rb +12 -4
- data/lib/sapience/version.rb +1 -1
- data/test_apps/rails/spec/workers/test_worker_spec.rb +1 -1
- metadata +2 -4
- data/test_apps/rails/spec/helpers/posts_helper_spec.rb +0 -15
- data/test_apps/rails/spec/models/user_spec.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a40c5a391a0e2ad10aa755042de77d26d213e054
|
4
|
+
data.tar.gz: 6b6a3e456552d94c7ee960a5e165a8758ad671f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19e50f5df3d0c2e851be3c83bffe2531f7d6307076944d074674a064bb840704645290212ac07bef382560cc39ad3228d805248b1a05933f82e6119db95123ce
|
7
|
+
data.tar.gz: f657142dd62de8b75a2ae17794956a6906f2fbf784b38e29e39e7505c592489483abc1cbfef61761868ce952379820a4070b69850e1201ef036c5924729507dd
|
data/.travis.yml
CHANGED
@@ -5,20 +5,25 @@ cache:
|
|
5
5
|
bundler: true
|
6
6
|
directories:
|
7
7
|
- $HOME/docker
|
8
|
+
- $BUNDLE_PATH
|
9
|
+
- ./vendor/bundle
|
8
10
|
|
9
11
|
services:
|
10
12
|
- docker
|
11
13
|
|
14
|
+
before_install:
|
15
|
+
- gem install bundler
|
16
|
+
|
17
|
+
install: bundle install --jobs 8 --retry 5
|
18
|
+
|
12
19
|
before_script:
|
13
20
|
- mkdir -p coverage/rails coverage/grape coverage/sapience
|
14
|
-
- bundle exec rake reevoocop
|
15
21
|
|
16
|
-
|
17
|
-
-
|
18
|
-
-
|
19
|
-
-
|
20
|
-
|
21
|
-
script: "docker-compose run $TEST_SUITE"
|
22
|
+
script:
|
23
|
+
- bundle exec rake reevoocop
|
24
|
+
- docker-compose run rspec
|
25
|
+
- docker-compose run rails
|
26
|
+
- docker-compose run grape
|
22
27
|
|
23
28
|
after_success:
|
24
29
|
- chown -R $(whoami) coverage
|
@@ -28,4 +33,5 @@ notifications:
|
|
28
33
|
slack:
|
29
34
|
on_success: change
|
30
35
|
on_failure: change
|
31
|
-
|
36
|
+
on_pull_requests: false
|
37
|
+
secure: apFwkfBQ+3NDJgcLNCHQori9qtr6ePaN3Xx7Sy7NVWwYm9BHNxoX/FN8/hxR63JjXrf1C0hK0FLQ0TiA0BN9PgEEIecg78BvWUwMClDDiwhyYN3H0Bbg35PUFtgDIrOGpu/TYlxNmdHEDYEAxaWsl9wSds8pAJsN6m7VTjGfBwJUDcOiM4L1eRpbp7smPqOjmuQFuOJnO8YkPb+6nUfz53cJrMRUdha89Vgmvnw6cP4/Ms1TsL3vKmMSVbGGh/6WNKPjU6IbuUjwlsh6a9xWxQOk6Wnis/Z+kA+T0XbLMuTLLmzRDuql1tjJeMPi+wukmK1a7GjpPkpkzAgwLQ/CkjTBfIRbMyaBYSuAciuOY8PDtCcT4WLwEvdZbkFmhAdSr1RYxIBpONVfZ/5DT3bpk71+O74OIBqxG6NmkiZ0B6u9/KxbnIINLVAcVaqsN8sdSqWlWKzPm45BfGPXGjmGGgIVFU31rs+W5Zs7IYMNUjZxabYKIv9TsBONbogfbcoGZA+rWWUnQdjypNWJS9wyQDvJ4btxqy8YhDfaV6gF30Un5JcAggMutzKJiYi+qAeh0uN3/9XoXV2N6XBnh58h8ny1NY+0vklWhtFGR1wfFAqkDskvCIZabSeJ5bFM6FtNbNKq9tYciS+eAO1vEYQVDFt9eY2uZF2mFDKRnEegHMU=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Sapience
|
2
2
|
|
3
|
-
**Hasslefree
|
3
|
+
**Hasslefree auto-configuration for logging, metrics and exception collection.**
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/reevoo/sapience-rb.svg?branch=master)](https://travis-ci.org/reevoo/sapience-rb)[![Code Climate](https://codeclimate.com/github/reevoo/sapience-rb/badges/gpa.svg)](https://codeclimate.com/github/reevoo/sapience-rb)[![Test Coverage](https://codeclimate.com/github/reevoo/sapience-rb/badges/coverage.svg)](https://codeclimate.com/github/reevoo/sapience-rb/coverage)[![Issue Count](https://codeclimate.com/github/reevoo/sapience-rb/badges/issue_count.svg)](https://codeclimate.com/github/reevoo/sapience-rb)
|
6
6
|
|
@@ -8,9 +8,9 @@
|
|
8
8
|
|
9
9
|
We searched long and hard for a way to control our logging, error collection and metrics from a single place. The closest we could find that does everything we need is [Semantic Logger](https://github.com/rocketjob/semantic_logger). Unfortunately we couldn't find a good way to control the settings for our projects and would have had to spread our configuration over different initializers and rails configurations for each project. There was no easy way to gain that top level control over the configuration.
|
10
10
|
|
11
|
-
This project aims to make it easier to
|
11
|
+
This project aims to make it easier to centralise the configuration of these three areas by handling the configuration a little differently.
|
12
12
|
|
13
|
-
We have taken a
|
13
|
+
We have taken a great deal of inspiration from the amazing [Semantic Logger](https://github.com/rocketjob/semantic_logger) and implemented something similar to [Rubocop](https://github.com/bbatsov/rubocop) for handling and overriding how to find configuration. If you want some inspiration for how we do something similar for our projects for Rubocop check: [Reevoocop](https://github.com/reevoo/reevoocop).
|
14
14
|
|
15
15
|
## Setup
|
16
16
|
|
@@ -19,13 +19,13 @@ First of all we need to require the right file for the project. There are curren
|
|
19
19
|
### Rails
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem "sapience
|
22
|
+
gem "sapience", require: "sapience/rails"
|
23
23
|
```
|
24
24
|
|
25
25
|
### Grape
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem "sapience
|
28
|
+
gem "sapience", require: "sapience/grape"
|
29
29
|
```
|
30
30
|
|
31
31
|
In your Base API class
|
@@ -107,7 +107,7 @@ production:
|
|
107
107
|
|
108
108
|
#### Configuration Inheritance
|
109
109
|
|
110
|
-
We will use our default (or overriden - see [reevoo_sapience-rb](https://github.com/reevoo/reevoo_sapience-rb) for more info) configuration as a base. Any configuration specified inside a `config/sapience.yml` file will then me merged into the default or
|
110
|
+
We will use our default (or overriden - see [reevoo_sapience-rb](https://github.com/reevoo/reevoo_sapience-rb) for more info) configuration as a base. Any configuration specified inside a `config/sapience.yml` file will then me merged into the default or overridden config.
|
111
111
|
|
112
112
|
The merge will take place not at the top level but at the environment level. This means that everything inside the environment keys will be replaced with a more specific application config.
|
113
113
|
|
@@ -115,7 +115,7 @@ Then if a configure block is used that will take presedence.
|
|
115
115
|
|
116
116
|
#### App name
|
117
117
|
|
118
|
-
Sapience requires an application name to be set for your
|
118
|
+
Sapience requires an application name to be set for your logs and such. We decided not to guess what name you want to give your application so there will be no magic involved here. There are 3 different ways of configuring the app_name for Sapience.
|
119
119
|
|
120
120
|
##### Environment variables
|
121
121
|
|
@@ -147,9 +147,9 @@ end
|
|
147
147
|
|
148
148
|
## Appenders
|
149
149
|
|
150
|
-
One of the things that did not
|
150
|
+
One of the things that did not suit us so well with the Semantic Logger approach was that they made a distinction between metrics and appenders. In our view anything that could potentially log something somewhere should be treated as an appender.
|
151
151
|
|
152
|
-
There are a number of appenders that
|
152
|
+
There are a number of appenders that each listen to different events and act on its data. It is possible to specify the `level` and `backtrace_level` for each appender by providing (example) `level: :error` to the add_appender method.
|
153
153
|
|
154
154
|
|
155
155
|
### Stream
|
@@ -163,7 +163,7 @@ Sapience.add_appender(:stream, io: STDOUT, formatter: :color, level: :trace)
|
|
163
163
|
|
164
164
|
### Sentry
|
165
165
|
|
166
|
-
The sentry appender handles sending errors to sentry. It's backtrace and log level can be configured by for instance `level: :info` and `backtrace_level: :debug`. The `level` configuration tells sentry to log starting at that level while the `backtrace_level` tells sentry to only collect backtrace starting at that level.
|
166
|
+
The sentry appender handles sending errors to [sentry](https://sentry.io). It's backtrace and log level can be configured by for instance `level: :info` and `backtrace_level: :debug`. The `level` configuration tells sentry to log starting at that level while the `backtrace_level` tells sentry to only collect backtrace starting at that level.
|
167
167
|
|
168
168
|
```ruby
|
169
169
|
Sapience.add_appender(
|
@@ -244,8 +244,8 @@ Formatters can be specified by using the key `formatter: :camelized_formatter_na
|
|
244
244
|
|
245
245
|
## Environment variables
|
246
246
|
|
247
|
-
`APP_NAME` - If you want to provide an application name for sapience it can be done here.
|
248
|
-
`SAPIENCE_ENV` - For applications that don't use rack or rails
|
247
|
+
- `APP_NAME` - If you want to provide an application name for sapience it can be done here.
|
248
|
+
- `SAPIENCE_ENV` - For applications that don't use rack or rails
|
249
249
|
|
250
250
|
## Contributing
|
251
251
|
|
@@ -1,5 +1,9 @@
|
|
1
|
-
|
2
|
-
require "active_support
|
1
|
+
begin
|
2
|
+
require "active_support"
|
3
|
+
require "active_support/notifications"
|
4
|
+
rescue LoadError
|
5
|
+
warn "ActiveSupport not available"
|
6
|
+
end
|
3
7
|
|
4
8
|
module Sapience
|
5
9
|
module Extensions
|
@@ -11,8 +15,12 @@ module Sapience
|
|
11
15
|
end
|
12
16
|
|
13
17
|
def self.subscribe(pattern, &block)
|
14
|
-
|
15
|
-
|
18
|
+
if defined?(ActiveSupport::Notifications)
|
19
|
+
::ActiveSupport::Notifications.subscribe(pattern) do |*args|
|
20
|
+
block.call ::ActiveSupport::Notifications::Event.new(*args)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
warn "ActiveSupport not available"
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
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: 1.0.
|
4
|
+
version: 1.0.5
|
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: 2016-09-
|
12
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -422,11 +422,9 @@ files:
|
|
422
422
|
- test_apps/rails/spec/factories/posts.rb
|
423
423
|
- test_apps/rails/spec/factories/users.rb
|
424
424
|
- test_apps/rails/spec/fixtures/sapience.yml
|
425
|
-
- test_apps/rails/spec/helpers/posts_helper_spec.rb
|
426
425
|
- test_apps/rails/spec/integration/sapience_spec.rb
|
427
426
|
- test_apps/rails/spec/jobs/test_job_spec.rb
|
428
427
|
- test_apps/rails/spec/models/post_spec.rb
|
429
|
-
- test_apps/rails/spec/models/user_spec.rb
|
430
428
|
- test_apps/rails/spec/rails_helper.rb
|
431
429
|
- test_apps/rails/spec/requests/posts_spec.rb
|
432
430
|
- test_apps/rails/spec/routing/posts_routing_spec.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
# Specs in this file have access to a helper object that includes
|
4
|
-
# the PostsHelper. For example:
|
5
|
-
#
|
6
|
-
# describe PostsHelper do
|
7
|
-
# describe "string concat" do
|
8
|
-
# it "concats two strings with spaces" do
|
9
|
-
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
-
# end
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
RSpec.describe PostsHelper, type: :helper do
|
14
|
-
pending "add some examples to (or delete) #{__FILE__}"
|
15
|
-
end
|