peastash 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +10 -10
- data/lib/peastash/version.rb +1 -1
- data/lib/peastash.rb +6 -1
- data/spec/peastash/middleware_spec.rb +5 -2
- data/spec/peastash_spec.rb +12 -8
- metadata +4 -4
- data/Gemfile.lock +0 -129
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae1c4247d347a2b0bbed42330c324909a05a289
|
4
|
+
data.tar.gz: ddee185247132b7067e3dd3e7db9041c88633414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3b0b19df08f1b3a01282c995dea4f4d1d128c58b3ca2986aa0df6acc03acc8937fbf4f9643a8c57cbdcf2194757195ac03ffd64d5b5d8f4d6f0f54cb0c99d63
|
7
|
+
data.tar.gz: a93bedc2e49cfe10ec896af5129b24672e4524df83ecbc39a1c3a507543c80fde302ab7b8fa6938d53fe67c8680611f3b0b4856d8f9af78e95d439feb4efedaf
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -23,8 +23,8 @@ gem 'peastash'
|
|
23
23
|
|
24
24
|
### Getting started
|
25
25
|
``Peastash`` provides a simple interface to aggregate data to be sent to Logstash.
|
26
|
-
The boundaries of a log entry are defined by
|
27
|
-
When the code inside the block is done running a log entry will be created and written.
|
26
|
+
The boundaries of a log entry are defined by the ``Peastash.with_instance.log`` block.
|
27
|
+
When the code inside the block is done running, a log entry will be created and written.
|
28
28
|
The most basic usage would look like:
|
29
29
|
|
30
30
|
```ruby
|
@@ -63,9 +63,9 @@ Please note that this is a global setting and cannot be set per-instance.
|
|
63
63
|
|
64
64
|
#### Outputs
|
65
65
|
|
66
|
-
Peastash ships with a single output: ``Peastash::Outputs::IO``. It can be initialized either by passing it path or an IO object.
|
66
|
+
Peastash ships with a single output: ``Peastash::Outputs::IO``. It can be initialized either by passing it a path or an IO object.
|
67
67
|
Peastash can easily be extended to output to any target.
|
68
|
-
Simply configure Peastash's output with an object that responds to the ``#dump`` method. This method will be called at the end of the ``#log`` block, with 1 argument
|
68
|
+
Simply configure Peastash's output with an object that responds to the ``#dump`` method. This method will be called at the end of the ``#log`` block, with 1 argument: a ``LogStash::Event`` object that you will probably need to serialize to json.
|
69
69
|
|
70
70
|
### What if I want to use it in my rack app?
|
71
71
|
|
@@ -77,7 +77,7 @@ use Peastash::Middleware
|
|
77
77
|
```
|
78
78
|
|
79
79
|
By default, the middleware only adds the ``duration``, ``status`` and ``hostname`` (machine name) fields to the log entry.
|
80
|
-
In addition to using ``Peastash.with_instance.store`` to add information, you can pass one or two block arguments to ``use
|
80
|
+
In addition to using ``Peastash.with_instance.store`` to add information, you can pass one or two block arguments to the ``use`` dsl, that will be called with the request ``env`` and the Rack response in parameter, in the context of the Middleware's instance.
|
81
81
|
The first block will be called **before** the request (with a ``response = nil``), while the second one will be called **after**, with the actual response. For example:
|
82
82
|
|
83
83
|
```ruby
|
@@ -103,7 +103,7 @@ config.peastash.source = Rails.application.class.parent_name
|
|
103
103
|
|
104
104
|
By default, Peastash's Rails integration will log the same parameters as the Middleware version, plus the fields in the payload of the [``process_action.action_controller``](http://edgeguides.rubyonrails.org/active_support_instrumentation.html#process_action.action_controller) notification (except the params).
|
105
105
|
|
106
|
-
All the options for ``Peastash`` can be set using the ``config.peastash``
|
106
|
+
All the options for ``Peastash`` can be set using the ``config.peastash`` configuration object.
|
107
107
|
|
108
108
|
#### Logging request parameters
|
109
109
|
|
@@ -113,7 +113,7 @@ To enable parameter logging, you must add the following to your configuration:
|
|
113
113
|
config.peastash.log_parameters = true
|
114
114
|
```
|
115
115
|
|
116
|
-
Be careful, as this can significantly increase the size of the log entries, as well as causing
|
116
|
+
Be careful, as this can significantly increase the size of the log entries, as well as causing issues if other Logstash entries have the same field with a different data type.
|
117
117
|
|
118
118
|
#### Listening to ``ActiveSupport::Notifications``
|
119
119
|
Additionaly, you can use Peastash to aggregate data from any ``ActiveSupport::Notifications``:
|
@@ -156,10 +156,10 @@ Using several instances, you can nest ``log`` blocks without sharing the store,
|
|
156
156
|
For example, you can log your Rails query with the ``global`` instance, and your asynchronous jobs with a ``worker`` instance, and have those instances output to different files.
|
157
157
|
|
158
158
|
### Playing with tags
|
159
|
-
There are three ways to tag your log entries in Peastash.with_instance
|
159
|
+
There are three ways to tag your log entries in ``Peastash.with_instance``.
|
160
160
|
|
161
|
-
* The first one is through configuration (see above)
|
162
|
-
* The second one is by passing tags to the ``Peastash.with_instance.log`` method
|
161
|
+
* The first one is through configuration (see above)
|
162
|
+
* The second one is by passing tags to the ``Peastash.with_instance.log`` method
|
163
163
|
* The last one is to call the ``Peastash.with_instance.tags`` method from within a ``Peastash.with_instance.log`` block. Tags defined with this method are not persistent and will disappear at the next call to ``Peastash.with_instance.log``
|
164
164
|
|
165
165
|
For example:
|
data/lib/peastash/version.rb
CHANGED
data/lib/peastash.rb
CHANGED
@@ -115,6 +115,11 @@ class Peastash
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def build_event(source, tags)
|
118
|
-
LogStash::Event.new(
|
118
|
+
LogStash::Event.new({
|
119
|
+
'@source' => source,
|
120
|
+
'@fields' => store,
|
121
|
+
'@tags' => @base_tags + tags,
|
122
|
+
'@pid' => Process.pid
|
123
|
+
})
|
119
124
|
end
|
120
125
|
end
|
@@ -53,7 +53,8 @@ describe Peastash::Middleware do
|
|
53
53
|
expect(LogStash::Event).to receive(:new).with({
|
54
54
|
'@source' => Peastash::STORE_NAME,
|
55
55
|
'@fields' => { path: '/', duration: 0, status: 200, ip: nil },
|
56
|
-
'@tags' => []
|
56
|
+
'@tags' => [],
|
57
|
+
'@pid' => an_instance_of(Fixnum),
|
57
58
|
})
|
58
59
|
Timecop.freeze { @middleware.call env_for('/') }
|
59
60
|
end
|
@@ -78,7 +79,8 @@ describe Peastash::Middleware do
|
|
78
79
|
expect(LogStash::Event).to receive(:new).with({
|
79
80
|
'@source' => Peastash::STORE_NAME,
|
80
81
|
'@fields' => { scheme: 'http', duration: 0, status: 200, ip: nil },
|
81
|
-
'@tags' => []
|
82
|
+
'@tags' => [],
|
83
|
+
'@pid' => an_instance_of(Fixnum),
|
82
84
|
})
|
83
85
|
Timecop.freeze { @middleware.call env_for('/') }
|
84
86
|
end
|
@@ -103,6 +105,7 @@ describe Peastash::Middleware do
|
|
103
105
|
'@source' => Peastash::STORE_NAME,
|
104
106
|
'@fields' => { duration: 0, status: 200, foo: 'foo', ip: nil },
|
105
107
|
'@tags' => [],
|
108
|
+
'@pid' => an_instance_of(Fixnum),
|
106
109
|
})
|
107
110
|
Timecop.freeze { @middleware.call env_for('/') }
|
108
111
|
end
|
data/spec/peastash_spec.rb
CHANGED
@@ -35,8 +35,9 @@ describe Peastash do
|
|
35
35
|
Peastash.with_instance.configure!(tags: tags)
|
36
36
|
expect(LogStash::Event).to receive(:new).with({
|
37
37
|
'@source' => Peastash::STORE_NAME,
|
38
|
-
'@fields' =>
|
39
|
-
'@tags' => tags
|
38
|
+
'@fields' => an_instance_of(Hash),
|
39
|
+
'@tags' => tags,
|
40
|
+
'@pid' => an_instance_of(Fixnum),
|
40
41
|
})
|
41
42
|
Peastash.with_instance.log {}
|
42
43
|
end
|
@@ -45,8 +46,9 @@ describe Peastash do
|
|
45
46
|
Peastash.with_instance.configure!(source: 'foo')
|
46
47
|
expect(LogStash::Event).to receive(:new).with({
|
47
48
|
'@source' => 'foo',
|
48
|
-
'@fields' =>
|
49
|
-
'@tags' => []
|
49
|
+
'@fields' => an_instance_of(Hash),
|
50
|
+
'@tags' => [],
|
51
|
+
'@pid' => an_instance_of(Fixnum),
|
50
52
|
})
|
51
53
|
Peastash.with_instance.log {}
|
52
54
|
end
|
@@ -118,8 +120,9 @@ describe Peastash do
|
|
118
120
|
Peastash.with_instance.configure!(tags: base_tags)
|
119
121
|
expect(LogStash::Event).to receive(:new).with({
|
120
122
|
'@source' => Peastash::STORE_NAME,
|
121
|
-
'@fields' =>
|
122
|
-
'@tags' => base_tags + tags
|
123
|
+
'@fields' => an_instance_of(Hash),
|
124
|
+
'@tags' => base_tags + tags,
|
125
|
+
'@pid' => an_instance_of(Fixnum),
|
123
126
|
})
|
124
127
|
Peastash.with_instance.log(tags) {}
|
125
128
|
end
|
@@ -177,8 +180,9 @@ describe Peastash do
|
|
177
180
|
Peastash.with_instance.configure!(tags: base_tags)
|
178
181
|
expect(LogStash::Event).to receive(:new).with({
|
179
182
|
'@source' => Peastash::STORE_NAME,
|
180
|
-
'@fields' =>
|
181
|
-
'@tags' => base_tags + tags + additional_tags
|
183
|
+
'@fields' => an_instance_of(Hash),
|
184
|
+
'@tags' => base_tags + tags + additional_tags,
|
185
|
+
'@pid' => an_instance_of(Fixnum),
|
182
186
|
})
|
183
187
|
Peastash.with_instance.log(tags) { Peastash.with_instance.tags.concat(additional_tags) }
|
184
188
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peastash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Boisard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-event
|
@@ -160,7 +160,6 @@ files:
|
|
160
160
|
- ".gitignore"
|
161
161
|
- ".travis.yml"
|
162
162
|
- Gemfile
|
163
|
-
- Gemfile.lock
|
164
163
|
- README.md
|
165
164
|
- Rakefile
|
166
165
|
- lib/peastash.rb
|
@@ -236,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
235
|
version: '0'
|
237
236
|
requirements: []
|
238
237
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.4.
|
238
|
+
rubygems_version: 2.4.2
|
240
239
|
signing_key:
|
241
240
|
specification_version: 4
|
242
241
|
summary: Peastash allows you to instrument your code with the ELK stack easily.
|
@@ -287,3 +286,4 @@ test_files:
|
|
287
286
|
- spec/peastash/rails_ext/watch_spec.rb
|
288
287
|
- spec/peastash_spec.rb
|
289
288
|
- spec/spec_helper.rb
|
289
|
+
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
peastash (0.0.9)
|
5
|
-
logstash-event
|
6
|
-
thread_safe
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actionmailer (4.1.1)
|
12
|
-
actionpack (= 4.1.1)
|
13
|
-
actionview (= 4.1.1)
|
14
|
-
mail (~> 2.5.4)
|
15
|
-
actionpack (4.1.1)
|
16
|
-
actionview (= 4.1.1)
|
17
|
-
activesupport (= 4.1.1)
|
18
|
-
rack (~> 1.5.2)
|
19
|
-
rack-test (~> 0.6.2)
|
20
|
-
actionview (4.1.1)
|
21
|
-
activesupport (= 4.1.1)
|
22
|
-
builder (~> 3.1)
|
23
|
-
erubis (~> 2.7.0)
|
24
|
-
activemodel (4.1.1)
|
25
|
-
activesupport (= 4.1.1)
|
26
|
-
builder (~> 3.1)
|
27
|
-
activerecord (4.1.1)
|
28
|
-
activemodel (= 4.1.1)
|
29
|
-
activesupport (= 4.1.1)
|
30
|
-
arel (~> 5.0.0)
|
31
|
-
activesupport (4.1.1)
|
32
|
-
i18n (~> 0.6, >= 0.6.9)
|
33
|
-
json (~> 1.7, >= 1.7.7)
|
34
|
-
minitest (~> 5.1)
|
35
|
-
thread_safe (~> 0.1)
|
36
|
-
tzinfo (~> 1.1)
|
37
|
-
arel (5.0.1.20140414130214)
|
38
|
-
builder (3.2.2)
|
39
|
-
coderay (1.1.0)
|
40
|
-
diff-lcs (1.2.5)
|
41
|
-
erubis (2.7.0)
|
42
|
-
hike (1.2.3)
|
43
|
-
i18n (0.6.9)
|
44
|
-
json (1.8.1)
|
45
|
-
logstash-event (1.2.02)
|
46
|
-
mail (2.5.4)
|
47
|
-
mime-types (~> 1.16)
|
48
|
-
treetop (~> 1.4.8)
|
49
|
-
method_source (0.8.2)
|
50
|
-
mime-types (1.25.1)
|
51
|
-
minitest (5.3.4)
|
52
|
-
multi_json (1.10.0)
|
53
|
-
polyglot (0.3.4)
|
54
|
-
pry (0.9.12.6)
|
55
|
-
coderay (~> 1.0)
|
56
|
-
method_source (~> 0.8)
|
57
|
-
slop (~> 3.4)
|
58
|
-
rack (1.5.2)
|
59
|
-
rack-test (0.6.2)
|
60
|
-
rack (>= 1.0)
|
61
|
-
rails (4.1.1)
|
62
|
-
actionmailer (= 4.1.1)
|
63
|
-
actionpack (= 4.1.1)
|
64
|
-
actionview (= 4.1.1)
|
65
|
-
activemodel (= 4.1.1)
|
66
|
-
activerecord (= 4.1.1)
|
67
|
-
activesupport (= 4.1.1)
|
68
|
-
bundler (>= 1.3.0, < 2.0)
|
69
|
-
railties (= 4.1.1)
|
70
|
-
sprockets-rails (~> 2.0)
|
71
|
-
railties (4.1.1)
|
72
|
-
actionpack (= 4.1.1)
|
73
|
-
activesupport (= 4.1.1)
|
74
|
-
rake (>= 0.8.7)
|
75
|
-
thor (>= 0.18.1, < 2.0)
|
76
|
-
rake (10.3.1)
|
77
|
-
rspec (2.14.1)
|
78
|
-
rspec-core (~> 2.14.0)
|
79
|
-
rspec-expectations (~> 2.14.0)
|
80
|
-
rspec-mocks (~> 2.14.0)
|
81
|
-
rspec-core (2.14.8)
|
82
|
-
rspec-expectations (2.14.5)
|
83
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
84
|
-
rspec-mocks (2.14.6)
|
85
|
-
rspec-rails (2.14.1)
|
86
|
-
actionpack (>= 3.0)
|
87
|
-
activemodel (>= 3.0)
|
88
|
-
activesupport (>= 3.0)
|
89
|
-
railties (>= 3.0)
|
90
|
-
rspec-core (~> 2.14.0)
|
91
|
-
rspec-expectations (~> 2.14.0)
|
92
|
-
rspec-mocks (~> 2.14.0)
|
93
|
-
simplecov (0.7.1)
|
94
|
-
multi_json (~> 1.0)
|
95
|
-
simplecov-html (~> 0.7.1)
|
96
|
-
simplecov-html (0.7.1)
|
97
|
-
slop (3.5.0)
|
98
|
-
sprockets (2.12.1)
|
99
|
-
hike (~> 1.2)
|
100
|
-
multi_json (~> 1.0)
|
101
|
-
rack (~> 1.0)
|
102
|
-
tilt (~> 1.1, != 1.3.0)
|
103
|
-
sprockets-rails (2.1.3)
|
104
|
-
actionpack (>= 3.0)
|
105
|
-
activesupport (>= 3.0)
|
106
|
-
sprockets (~> 2.8)
|
107
|
-
thor (0.19.1)
|
108
|
-
thread_safe (0.3.4)
|
109
|
-
tilt (1.4.1)
|
110
|
-
timecop (0.7.1)
|
111
|
-
treetop (1.4.15)
|
112
|
-
polyglot
|
113
|
-
polyglot (>= 0.3.1)
|
114
|
-
tzinfo (1.2.0)
|
115
|
-
thread_safe (~> 0.1)
|
116
|
-
|
117
|
-
PLATFORMS
|
118
|
-
ruby
|
119
|
-
|
120
|
-
DEPENDENCIES
|
121
|
-
peastash!
|
122
|
-
pry
|
123
|
-
rack-test
|
124
|
-
rails
|
125
|
-
rake
|
126
|
-
rspec (~> 2.14)
|
127
|
-
rspec-rails
|
128
|
-
simplecov (~> 0.7.1)
|
129
|
-
timecop
|