timber 2.0.24 → 2.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG +3 -0
- data/README.md +314 -59
- data/bin/timber +11 -2
- data/lib/timber.rb +2 -7
- data/lib/timber/cli.rb +16 -28
- data/lib/timber/cli/api.rb +80 -14
- data/lib/timber/cli/api/application.rb +30 -0
- data/lib/timber/cli/config_file.rb +66 -0
- data/lib/timber/cli/file_helper.rb +43 -0
- data/lib/timber/cli/installer.rb +58 -0
- data/lib/timber/cli/installers.rb +37 -0
- data/lib/timber/cli/installers/other.rb +47 -0
- data/lib/timber/cli/installers/rails.rb +255 -0
- data/lib/timber/cli/installers/root.rb +189 -0
- data/lib/timber/cli/io.rb +97 -0
- data/lib/timber/cli/io/ansi.rb +22 -0
- data/lib/timber/cli/io/messages.rb +213 -0
- data/lib/timber/cli/os_helper.rb +53 -0
- data/lib/timber/config.rb +97 -43
- data/lib/timber/config/integrations.rb +63 -0
- data/lib/timber/config/integrations/rack.rb +74 -0
- data/lib/timber/context.rb +13 -10
- data/lib/timber/contexts.rb +1 -0
- data/lib/timber/contexts/custom.rb +16 -3
- data/lib/timber/contexts/http.rb +10 -3
- data/lib/timber/contexts/organization.rb +4 -0
- data/lib/timber/contexts/release.rb +46 -0
- data/lib/timber/contexts/runtime.rb +7 -1
- data/lib/timber/contexts/session.rb +8 -1
- data/lib/timber/contexts/system.rb +5 -1
- data/lib/timber/contexts/user.rb +9 -2
- data/lib/timber/current_context.rb +43 -11
- data/lib/timber/events/controller_call.rb +4 -0
- data/lib/timber/events/custom.rb +13 -5
- data/lib/timber/events/exception.rb +4 -0
- data/lib/timber/events/http_client_request.rb +4 -0
- data/lib/timber/events/http_client_response.rb +4 -0
- data/lib/timber/events/http_server_request.rb +5 -0
- data/lib/timber/events/http_server_response.rb +15 -3
- data/lib/timber/events/sql_query.rb +3 -0
- data/lib/timber/events/template_render.rb +3 -0
- data/lib/timber/integration.rb +40 -0
- data/lib/timber/integrations.rb +21 -14
- data/lib/timber/integrations/action_controller.rb +18 -0
- data/lib/timber/integrations/action_controller/log_subscriber.rb +2 -0
- data/lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb +6 -0
- data/lib/timber/integrations/action_dispatch.rb +23 -0
- data/lib/timber/integrations/action_dispatch/debug_exceptions.rb +2 -0
- data/lib/timber/integrations/action_view.rb +18 -0
- data/lib/timber/integrations/action_view/log_subscriber.rb +2 -0
- data/lib/timber/integrations/action_view/log_subscriber/timber_log_subscriber.rb +10 -0
- data/lib/timber/integrations/active_record.rb +18 -0
- data/lib/timber/integrations/active_record/log_subscriber.rb +2 -0
- data/lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb +8 -0
- data/lib/timber/integrations/rack.rb +12 -2
- data/lib/timber/integrations/rack/exception_event.rb +38 -5
- data/lib/timber/integrations/rack/http_context.rb +4 -6
- data/lib/timber/integrations/rack/http_events.rb +177 -27
- data/lib/timber/integrations/rack/middleware.rb +28 -0
- data/lib/timber/integrations/rack/session_context.rb +5 -6
- data/lib/timber/integrations/rack/user_context.rb +90 -43
- data/lib/timber/integrations/rails.rb +22 -0
- data/lib/timber/integrations/rails/rack_logger.rb +2 -0
- data/lib/timber/integrator.rb +18 -3
- data/lib/timber/log_devices/http.rb +107 -99
- data/lib/timber/log_devices/http/dropping_sized_queue.rb +26 -0
- data/lib/timber/log_devices/http/flushable_sized_queue.rb +42 -0
- data/lib/timber/log_entry.rb +14 -2
- data/lib/timber/logger.rb +51 -36
- data/lib/timber/overrides.rb +2 -0
- data/lib/timber/overrides/active_support_3_tagged_logging.rb +103 -0
- data/lib/timber/overrides/active_support_tagged_logging.rb +53 -90
- data/lib/timber/timer.rb +21 -0
- data/lib/timber/util/hash.rb +1 -1
- data/lib/timber/util/http_event.rb +16 -3
- data/lib/timber/version.rb +1 -1
- data/spec/support/timber.rb +2 -3
- data/spec/timber/cli/installers/rails_spec.rb +160 -0
- data/spec/timber/cli/installers/root_spec.rb +100 -0
- data/spec/timber/config_spec.rb +28 -0
- data/spec/timber/current_context_spec.rb +61 -12
- data/spec/timber/events/custom_spec.rb +13 -2
- data/spec/timber/events/exception_spec.rb +15 -0
- data/spec/timber/events/http_server_request_spec.rb +3 -3
- data/spec/timber/integrations/rack/http_events_spec.rb +101 -0
- data/spec/timber/log_devices/http_spec.rb +20 -4
- data/spec/timber/log_entry_spec.rb +2 -1
- data/spec/timber/logger_spec.rb +8 -8
- metadata +40 -9
- data/benchmarks/rails.rb +0 -122
- data/lib/timber/cli/application.rb +0 -28
- data/lib/timber/cli/install.rb +0 -196
- data/lib/timber/cli/io_helper.rb +0 -65
- data/lib/timber/cli/messages.rb +0 -180
- data/lib/timber/integrations/active_support/tagged_logging.rb +0 -71
@@ -3,9 +3,20 @@ require "spec_helper"
|
|
3
3
|
describe Timber::Events::Custom, :rails_23 => true do
|
4
4
|
describe ".to_hash" do
|
5
5
|
it "should coerce type into an atom" do
|
6
|
-
|
7
|
-
hash =
|
6
|
+
custom_event = described_class.new(:type => "my type", :message => "hello", :data => {:key => "value"})
|
7
|
+
hash = custom_event.to_hash()
|
8
8
|
expect(hash.keys.first).to eq(:"my type")
|
9
9
|
end
|
10
|
+
|
11
|
+
it "should coerce a Time into a float representing fractional milliseconds" do
|
12
|
+
timer = Timber::Timer.start
|
13
|
+
sleep(0.25)
|
14
|
+
custom_event = described_class.new(:type => :my_event, :message => "hello", :data => {:time_ms => timer})
|
15
|
+
expect(custom_event.message).to include("in ")
|
16
|
+
expect(custom_event.message).to end_with("ms")
|
17
|
+
data = custom_event.data
|
18
|
+
expect(data[:time_ms]).to be_kind_of(Float)
|
19
|
+
expect(data[:time_ms]).to be > 0.0
|
20
|
+
end
|
10
21
|
end
|
11
22
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Timber::Events::Exception, :rails_23 => true do
|
4
|
+
describe ".initialize" do
|
5
|
+
it "should clean the backtrace" do
|
6
|
+
backtrace = [
|
7
|
+
"/path/to/file1.rb:26:in `function1'",
|
8
|
+
"path/to/file2.rb:86:in `function2'"
|
9
|
+
]
|
10
|
+
|
11
|
+
exception_event = described_class.new(name: "RuntimeError", exception_message: "Boom", backtrace: backtrace)
|
12
|
+
expect(exception_event.backtrace).to eq([{:file=>"/path/to/file1.rb", :line=>26, :function=>"function1"}, {:file=>"path/to/file2.rb", :line=>86, :function=>"function2"}])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -6,10 +6,10 @@ describe Timber::Events::HTTPServerRequest, :rails_23 => true do
|
|
6
6
|
describe ".initialize" do
|
7
7
|
context "with a header filters" do
|
8
8
|
around(:each) do |example|
|
9
|
-
|
10
|
-
Timber::Config.instance.
|
9
|
+
old_http_header_filters = Timber::Config.instance.http_header_filters
|
10
|
+
Timber::Config.instance.http_header_filters += ['api-key']
|
11
11
|
example.run
|
12
|
-
Timber::Config.instance.
|
12
|
+
Timber::Config.instance.http_header_filters = old_http_header_filters
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should sanitize headers when a config option is set" do
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
if defined?(::Rack)
|
4
|
+
describe Timber::Integrations::Rack::HTTPEvents do
|
5
|
+
let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
|
6
|
+
let(:io) { StringIO.new }
|
7
|
+
let(:logger) do
|
8
|
+
logger = Timber::Logger.new(io)
|
9
|
+
logger.level = ::Logger::INFO
|
10
|
+
logger
|
11
|
+
end
|
12
|
+
|
13
|
+
around(:each) do |example|
|
14
|
+
class RackHttpController < ActionController::Base
|
15
|
+
layout nil
|
16
|
+
|
17
|
+
def index
|
18
|
+
Thread.current[:_timber_context_snapshot] = Timber::CurrentContext.instance.snapshot
|
19
|
+
render json: {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_for_action(action_name)
|
23
|
+
action_name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
::RailsApp.routes.draw do
|
28
|
+
get '/rack_http' => 'rack_http#index'
|
29
|
+
end
|
30
|
+
|
31
|
+
with_rails_logger(logger) do
|
32
|
+
Timecop.freeze(time) { example.run }
|
33
|
+
end
|
34
|
+
|
35
|
+
Object.send(:remove_const, :RackHttpController)
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#process" do
|
39
|
+
it "should log the events" do
|
40
|
+
allow(Benchmark).to receive(:ms).and_return(1).and_yield
|
41
|
+
|
42
|
+
dispatch_rails_request("/rack_http")
|
43
|
+
|
44
|
+
lines = clean_lines(io.string.split("\n"))
|
45
|
+
expect(lines.length).to eq(3)
|
46
|
+
|
47
|
+
expect(lines[0]).to start_with("Started GET \"/rack_http\" @metadata ")
|
48
|
+
expect(lines[1]).to start_with("Processing by RackHttpController#index as HTML @metadata ")
|
49
|
+
expect(lines[2]).to start_with("Completed 200 OK in 0.0ms @metadata ")
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with the route silenced" do
|
53
|
+
around(:each) do |example|
|
54
|
+
described_class.silence_request = lambda do |rack_env, rack_request|
|
55
|
+
rack_request.path == "/rack_http"
|
56
|
+
end
|
57
|
+
|
58
|
+
example.run
|
59
|
+
|
60
|
+
described_class.silence_request = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should silence the logs" do
|
64
|
+
allow(Benchmark).to receive(:ms).and_return(1).and_yield
|
65
|
+
|
66
|
+
dispatch_rails_request("/rack_http")
|
67
|
+
|
68
|
+
lines = clean_lines(io.string.split("\n"))
|
69
|
+
expect(lines.length).to eq(0)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "collapsed into a single event" do
|
74
|
+
around(:each) do |example|
|
75
|
+
described_class.collapse_into_single_event = true
|
76
|
+
|
77
|
+
example.run
|
78
|
+
|
79
|
+
described_class.collapse_into_single_event = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should silence the logs" do
|
83
|
+
allow(Benchmark).to receive(:ms).and_return(1).and_yield
|
84
|
+
|
85
|
+
dispatch_rails_request("/rack_http")
|
86
|
+
|
87
|
+
lines = clean_lines(io.string.split("\n"))
|
88
|
+
expect(lines.length).to eq(2)
|
89
|
+
|
90
|
+
expect(lines[0]).to start_with("Processing by RackHttpController#index as HTML @metadata ")
|
91
|
+
expect(lines[1]).to start_with("GET /rack_http sent 200 OK in 0.0ms @metadata ")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Remove blank lines since Rails does this to space out requests in the logs
|
97
|
+
def clean_lines(lines)
|
98
|
+
lines.select { |line| !line.start_with?(" @metadat") }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -42,7 +42,7 @@ describe Timber::LogDevices::HTTP do
|
|
42
42
|
|
43
43
|
it "should attempt a delivery when the limit is exceeded" do
|
44
44
|
http.write("test")
|
45
|
-
expect(http).to receive(:
|
45
|
+
expect(http).to receive(:flush_async).exactly(1).times
|
46
46
|
http.write("my log message")
|
47
47
|
expect(http).to receive(:flush).exactly(1).times
|
48
48
|
http.close
|
@@ -76,13 +76,29 @@ describe Timber::LogDevices::HTTP do
|
|
76
76
|
describe "#flush" do
|
77
77
|
let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
|
78
78
|
|
79
|
-
it "should
|
79
|
+
it "should deliver the request" do
|
80
80
|
http = described_class.new("MYKEY", flush_continuously: false)
|
81
81
|
log_entry = Timber::LogEntry.new("INFO", time, nil, "test log message 1", nil, nil)
|
82
82
|
http.write(log_entry)
|
83
83
|
log_entry = Timber::LogEntry.new("INFO", time, nil, "test log message 2", nil, nil)
|
84
84
|
http.write(log_entry)
|
85
|
+
expect(http).to receive(:flush_async).exactly(2).times
|
85
86
|
http.send(:flush)
|
87
|
+
http.close
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Testing a private method because it helps break down our tests
|
92
|
+
describe "#flush_async" do
|
93
|
+
let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
|
94
|
+
|
95
|
+
it "should add a request to the queue" do
|
96
|
+
http = described_class.new("MYKEY", flush_continuously: false)
|
97
|
+
log_entry = Timber::LogEntry.new("INFO", time, nil, "test log message 1", nil, nil)
|
98
|
+
http.write(log_entry)
|
99
|
+
log_entry = Timber::LogEntry.new("INFO", time, nil, "test log message 2", nil, nil)
|
100
|
+
http.write(log_entry)
|
101
|
+
http.send(:flush_async)
|
86
102
|
request_queue = http.instance_variable_get(:@request_queue)
|
87
103
|
request = request_queue.deq
|
88
104
|
expect(request).to be_kind_of(Net::HTTP::Post)
|
@@ -98,8 +114,8 @@ describe Timber::LogDevices::HTTP do
|
|
98
114
|
it "should start a intervaled flush thread and flush on an interval" do
|
99
115
|
http = described_class.new("MYKEY", flush_interval: 0.1)
|
100
116
|
http.send(:ensure_flush_threads_are_started)
|
101
|
-
expect(http).to receive(:
|
102
|
-
sleep
|
117
|
+
expect(http).to receive(:flush_async).at_least(3).times
|
118
|
+
sleep 1.1 # iterations check every 0.5 seconds
|
103
119
|
http.close
|
104
120
|
end
|
105
121
|
end
|
@@ -6,7 +6,8 @@ describe Timber::LogEntry, :rails_23 => true do
|
|
6
6
|
describe "#to_msgpack" do
|
7
7
|
it "should encode properly with an event and context" do
|
8
8
|
event = Timber::Events::Custom.new(type: :event_type, message: "event_message", data: {a: 1})
|
9
|
-
|
9
|
+
custom_context = Timber::Contexts::Custom.new(type: :context_type, data: {b: 1})
|
10
|
+
context = {custom: custom_context.as_json}
|
10
11
|
log_entry = described_class.new("INFO", time, nil, "log message", context, event)
|
11
12
|
msgpack = log_entry.to_msgpack
|
12
13
|
expect(msgpack).to start_with("\x86\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z".force_encoding("ASCII-8BIT"))
|
data/spec/timber/logger_spec.rb
CHANGED
@@ -10,8 +10,8 @@ describe Timber::Logger, :rails_23 => true do
|
|
10
10
|
Timecop.freeze(time) { example.run }
|
11
11
|
end
|
12
12
|
|
13
|
-
context "with the
|
14
|
-
before(:each) { logger.formatter = Timber::Logger::
|
13
|
+
context "with the AugmentedFormatter" do
|
14
|
+
before(:each) { logger.formatter = Timber::Logger::AugmentedFormatter.new }
|
15
15
|
|
16
16
|
it "should accept strings" do
|
17
17
|
logger.info("this is a test")
|
@@ -91,7 +91,7 @@ describe Timber::Logger, :rails_23 => true do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
context "with the
|
94
|
+
context "with the JSONFormatter" do
|
95
95
|
before(:each) { logger.formatter = Timber::Logger::JSONFormatter.new }
|
96
96
|
|
97
97
|
it "should log in the correct format" do
|
@@ -129,19 +129,19 @@ describe Timber::Logger, :rails_23 => true do
|
|
129
129
|
let(:logger) { Timber::Logger.new(io) }
|
130
130
|
|
131
131
|
it "should add context" do
|
132
|
-
expect(Timber::CurrentContext.hash).to eq({})
|
132
|
+
expect(Timber::CurrentContext.instance.send(:hash)).to eq({})
|
133
133
|
|
134
134
|
logger.with_context(build: {version: "1.0.0"}) do
|
135
|
-
expect(Timber::CurrentContext.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})
|
135
|
+
expect(Timber::CurrentContext.instance.send(:hash)).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})
|
136
136
|
|
137
137
|
logger.with_context({testing: {key: "value"}}) do
|
138
|
-
expect(Timber::CurrentContext.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}}})
|
138
|
+
expect(Timber::CurrentContext.instance.send(:hash)).to eq({:custom=>{:build=>{:version=>"1.0.0"}, :testing=>{:key=>"value"}}})
|
139
139
|
end
|
140
140
|
|
141
|
-
expect(Timber::CurrentContext.hash).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})
|
141
|
+
expect(Timber::CurrentContext.instance.send(:hash)).to eq({:custom=>{:build=>{:version=>"1.0.0"}}})
|
142
142
|
end
|
143
143
|
|
144
|
-
expect(Timber::CurrentContext.hash).to eq({})
|
144
|
+
expect(Timber::CurrentContext.instance.send(:hash)).to eq({})
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timber Technologies, Inc.
|
@@ -134,10 +134,10 @@ files:
|
|
134
134
|
- ".rspec"
|
135
135
|
- ".travis.yml"
|
136
136
|
- ".yardopts"
|
137
|
+
- CHANGELOG
|
137
138
|
- Gemfile
|
138
139
|
- LICENSE.md
|
139
140
|
- README.md
|
140
|
-
- benchmarks/rails.rb
|
141
141
|
- bin/timber
|
142
142
|
- gemfiles/rails-3.0.gemfile
|
143
143
|
- gemfiles/rails-3.1.gemfile
|
@@ -151,16 +151,27 @@ files:
|
|
151
151
|
- lib/timber.rb
|
152
152
|
- lib/timber/cli.rb
|
153
153
|
- lib/timber/cli/api.rb
|
154
|
-
- lib/timber/cli/application.rb
|
155
|
-
- lib/timber/cli/
|
156
|
-
- lib/timber/cli/
|
157
|
-
- lib/timber/cli/
|
154
|
+
- lib/timber/cli/api/application.rb
|
155
|
+
- lib/timber/cli/config_file.rb
|
156
|
+
- lib/timber/cli/file_helper.rb
|
157
|
+
- lib/timber/cli/installer.rb
|
158
|
+
- lib/timber/cli/installers.rb
|
159
|
+
- lib/timber/cli/installers/other.rb
|
160
|
+
- lib/timber/cli/installers/rails.rb
|
161
|
+
- lib/timber/cli/installers/root.rb
|
162
|
+
- lib/timber/cli/io.rb
|
163
|
+
- lib/timber/cli/io/ansi.rb
|
164
|
+
- lib/timber/cli/io/messages.rb
|
165
|
+
- lib/timber/cli/os_helper.rb
|
158
166
|
- lib/timber/config.rb
|
167
|
+
- lib/timber/config/integrations.rb
|
168
|
+
- lib/timber/config/integrations/rack.rb
|
159
169
|
- lib/timber/context.rb
|
160
170
|
- lib/timber/contexts.rb
|
161
171
|
- lib/timber/contexts/custom.rb
|
162
172
|
- lib/timber/contexts/http.rb
|
163
173
|
- lib/timber/contexts/organization.rb
|
174
|
+
- lib/timber/contexts/release.rb
|
164
175
|
- lib/timber/contexts/runtime.rb
|
165
176
|
- lib/timber/contexts/session.rb
|
166
177
|
- lib/timber/contexts/system.rb
|
@@ -179,31 +190,41 @@ files:
|
|
179
190
|
- lib/timber/events/template_render.rb
|
180
191
|
- lib/timber/frameworks.rb
|
181
192
|
- lib/timber/frameworks/rails.rb
|
193
|
+
- lib/timber/integration.rb
|
182
194
|
- lib/timber/integrations.rb
|
195
|
+
- lib/timber/integrations/action_controller.rb
|
183
196
|
- lib/timber/integrations/action_controller/log_subscriber.rb
|
184
197
|
- lib/timber/integrations/action_controller/log_subscriber/timber_log_subscriber.rb
|
198
|
+
- lib/timber/integrations/action_dispatch.rb
|
185
199
|
- lib/timber/integrations/action_dispatch/debug_exceptions.rb
|
200
|
+
- lib/timber/integrations/action_view.rb
|
186
201
|
- lib/timber/integrations/action_view/log_subscriber.rb
|
187
202
|
- lib/timber/integrations/action_view/log_subscriber/timber_log_subscriber.rb
|
203
|
+
- lib/timber/integrations/active_record.rb
|
188
204
|
- lib/timber/integrations/active_record/log_subscriber.rb
|
189
205
|
- lib/timber/integrations/active_record/log_subscriber/timber_log_subscriber.rb
|
190
|
-
- lib/timber/integrations/active_support/tagged_logging.rb
|
191
206
|
- lib/timber/integrations/rack.rb
|
192
207
|
- lib/timber/integrations/rack/exception_event.rb
|
193
208
|
- lib/timber/integrations/rack/http_context.rb
|
194
209
|
- lib/timber/integrations/rack/http_events.rb
|
210
|
+
- lib/timber/integrations/rack/middleware.rb
|
195
211
|
- lib/timber/integrations/rack/session_context.rb
|
196
212
|
- lib/timber/integrations/rack/user_context.rb
|
213
|
+
- lib/timber/integrations/rails.rb
|
197
214
|
- lib/timber/integrations/rails/rack_logger.rb
|
198
215
|
- lib/timber/integrator.rb
|
199
216
|
- lib/timber/log_devices.rb
|
200
217
|
- lib/timber/log_devices/http.rb
|
218
|
+
- lib/timber/log_devices/http/dropping_sized_queue.rb
|
219
|
+
- lib/timber/log_devices/http/flushable_sized_queue.rb
|
201
220
|
- lib/timber/log_entry.rb
|
202
221
|
- lib/timber/logger.rb
|
203
222
|
- lib/timber/overrides.rb
|
223
|
+
- lib/timber/overrides/active_support_3_tagged_logging.rb
|
204
224
|
- lib/timber/overrides/active_support_tagged_logging.rb
|
205
225
|
- lib/timber/overrides/lograge.rb
|
206
226
|
- lib/timber/overrides/rails_stdout_logging.rb
|
227
|
+
- lib/timber/timer.rb
|
207
228
|
- lib/timber/util.rb
|
208
229
|
- lib/timber/util/active_support_log_subscriber.rb
|
209
230
|
- lib/timber/util/hash.rb
|
@@ -225,6 +246,9 @@ files:
|
|
225
246
|
- spec/support/timber.rb
|
226
247
|
- spec/support/timecop.rb
|
227
248
|
- spec/support/webmock.rb
|
249
|
+
- spec/timber/cli/installers/rails_spec.rb
|
250
|
+
- spec/timber/cli/installers/root_spec.rb
|
251
|
+
- spec/timber/config_spec.rb
|
228
252
|
- spec/timber/contexts/custom_spec.rb
|
229
253
|
- spec/timber/contexts/organization_spec.rb
|
230
254
|
- spec/timber/contexts/system_spec.rb
|
@@ -234,6 +258,7 @@ files:
|
|
234
258
|
- spec/timber/event_spec.rb
|
235
259
|
- spec/timber/events/controller_call_spec.rb
|
236
260
|
- spec/timber/events/custom_spec.rb
|
261
|
+
- spec/timber/events/exception_spec.rb
|
237
262
|
- spec/timber/events/http_server_request_spec.rb
|
238
263
|
- spec/timber/events_spec.rb
|
239
264
|
- spec/timber/integrations/action_controller/log_subscriber_spec.rb
|
@@ -241,6 +266,7 @@ files:
|
|
241
266
|
- spec/timber/integrations/action_view/log_subscriber_spec.rb
|
242
267
|
- spec/timber/integrations/active_record/log_subscriber_spec.rb
|
243
268
|
- spec/timber/integrations/rack/http_context_spec.rb
|
269
|
+
- spec/timber/integrations/rack/http_events_spec.rb
|
244
270
|
- spec/timber/integrations/rails/rack_logger_spec.rb
|
245
271
|
- spec/timber/log_devices/http_spec.rb
|
246
272
|
- spec/timber/log_entry_spec.rb
|
@@ -262,9 +288,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
288
|
version: 1.9.0
|
263
289
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
290
|
requirements:
|
265
|
-
- - "
|
291
|
+
- - ">"
|
266
292
|
- !ruby/object:Gem::Version
|
267
|
-
version:
|
293
|
+
version: 1.3.1
|
268
294
|
requirements: []
|
269
295
|
rubyforge_project:
|
270
296
|
rubygems_version: 2.4.5.2
|
@@ -284,6 +310,9 @@ test_files:
|
|
284
310
|
- spec/support/timber.rb
|
285
311
|
- spec/support/timecop.rb
|
286
312
|
- spec/support/webmock.rb
|
313
|
+
- spec/timber/cli/installers/rails_spec.rb
|
314
|
+
- spec/timber/cli/installers/root_spec.rb
|
315
|
+
- spec/timber/config_spec.rb
|
287
316
|
- spec/timber/contexts/custom_spec.rb
|
288
317
|
- spec/timber/contexts/organization_spec.rb
|
289
318
|
- spec/timber/contexts/system_spec.rb
|
@@ -293,6 +322,7 @@ test_files:
|
|
293
322
|
- spec/timber/event_spec.rb
|
294
323
|
- spec/timber/events/controller_call_spec.rb
|
295
324
|
- spec/timber/events/custom_spec.rb
|
325
|
+
- spec/timber/events/exception_spec.rb
|
296
326
|
- spec/timber/events/http_server_request_spec.rb
|
297
327
|
- spec/timber/events_spec.rb
|
298
328
|
- spec/timber/integrations/action_controller/log_subscriber_spec.rb
|
@@ -300,6 +330,7 @@ test_files:
|
|
300
330
|
- spec/timber/integrations/action_view/log_subscriber_spec.rb
|
301
331
|
- spec/timber/integrations/active_record/log_subscriber_spec.rb
|
302
332
|
- spec/timber/integrations/rack/http_context_spec.rb
|
333
|
+
- spec/timber/integrations/rack/http_events_spec.rb
|
303
334
|
- spec/timber/integrations/rails/rack_logger_spec.rb
|
304
335
|
- spec/timber/log_devices/http_spec.rb
|
305
336
|
- spec/timber/log_entry_spec.rb
|
data/benchmarks/rails.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
require 'benchmark-memory'
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'rails'
|
5
|
-
require 'action_controller'
|
6
|
-
|
7
|
-
io = StringIO.new # ensure we are logging to something
|
8
|
-
logger = Logger.new(io)
|
9
|
-
logger.level = Logger::DEBUG
|
10
|
-
Rails.logger = logger
|
11
|
-
|
12
|
-
#
|
13
|
-
# Setup
|
14
|
-
#
|
15
|
-
|
16
|
-
# Setup the rails app to test
|
17
|
-
class RailsApp < Rails::Application
|
18
|
-
if ::Rails.version =~ /^3\./
|
19
|
-
config.secret_token = '1e05af2b349457936a41427e63450937'
|
20
|
-
else
|
21
|
-
config.secret_key_base = '1e05af2b349457936a41427e63450937'
|
22
|
-
end
|
23
|
-
|
24
|
-
# This ensures our tests fail, otherwise exceptions get swallowed by ActionDispatch::DebugExceptions
|
25
|
-
config.action_dispatch.show_exceptions = false
|
26
|
-
config.active_support.deprecation = :stderr
|
27
|
-
config.eager_load = false
|
28
|
-
end
|
29
|
-
|
30
|
-
# Create a controller to test against
|
31
|
-
class HomeController < ActionController::Base
|
32
|
-
layout nil
|
33
|
-
|
34
|
-
def index
|
35
|
-
render json: {}
|
36
|
-
end
|
37
|
-
|
38
|
-
def method_for_action(action_name)
|
39
|
-
action_name
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Define the routes
|
44
|
-
::RailsApp.routes.draw do
|
45
|
-
get '/' => 'home#index'
|
46
|
-
end
|
47
|
-
|
48
|
-
# Initialize the app
|
49
|
-
RailsApp.initialize!
|
50
|
-
|
51
|
-
# Helper function to issue requests.
|
52
|
-
def dispatch_rails_request(path, additional_env_options = {})
|
53
|
-
application = ::Rails.application
|
54
|
-
env = application.respond_to?(:env_config) ? application.env_config.clone : application.env_defaults.clone
|
55
|
-
env["rack.request.cookie_hash"] = {}.with_indifferent_access
|
56
|
-
env["REMOTE_ADDR"] = "123.456.789.10"
|
57
|
-
env["HTTP_X_REQUEST_ID"] = "unique-request-id-1234"
|
58
|
-
env["action_dispatch.request_id"] = env["HTTP_X_REQUEST_ID"]
|
59
|
-
env = env.merge(additional_env_options)
|
60
|
-
::Rack::MockRequest.new(application).get(path, env)
|
61
|
-
end
|
62
|
-
|
63
|
-
# How many iterations to perform
|
64
|
-
iterations = 1_000
|
65
|
-
|
66
|
-
puts "############################################################"
|
67
|
-
puts ""
|
68
|
-
puts "Testing Without Timber (#{iterations} iterations)"
|
69
|
-
puts ""
|
70
|
-
puts "############################################################"
|
71
|
-
puts
|
72
|
-
|
73
|
-
# Use bmbm to mimimize initial GC differences.
|
74
|
-
puts "Timing via benchmark:"
|
75
|
-
puts ""
|
76
|
-
|
77
|
-
Benchmark.bmbm do |x|
|
78
|
-
x.report("Without Timber") { iterations.times { dispatch_rails_request("/") } }
|
79
|
-
end
|
80
|
-
|
81
|
-
puts "\n"
|
82
|
-
puts "Memory profiling via benchmark-memory:"
|
83
|
-
puts
|
84
|
-
|
85
|
-
Benchmark.memory do |x|
|
86
|
-
x.report("Without Timber") { iterations.times { dispatch_rails_request("/") } }
|
87
|
-
end
|
88
|
-
|
89
|
-
puts "\n\n\n\n"
|
90
|
-
puts "############################################################"
|
91
|
-
puts ""
|
92
|
-
puts "Testing With Timber (#{iterations} iterations)"
|
93
|
-
puts ""
|
94
|
-
puts "############################################################"
|
95
|
-
puts ""
|
96
|
-
|
97
|
-
# Integrate Timber (this is handled in our Railtie, but we cna't use that here since we already
|
98
|
-
# initialized the app.)
|
99
|
-
require 'timber'
|
100
|
-
io = StringIO.new # ensure we are logging to something
|
101
|
-
logger = Timber::Logger.new(io)
|
102
|
-
logger.level = Logger::DEBUG
|
103
|
-
Timber::Frameworks::Rails.set_logger(logger)
|
104
|
-
Timber::Frameworks::Rails.configure_middlewares(Rails.application.config.app_middleware)
|
105
|
-
Timber::Integrations.integrate!
|
106
|
-
Timber::Config.instance.append_metadata = false
|
107
|
-
|
108
|
-
|
109
|
-
puts "Timing via benchmark:"
|
110
|
-
puts ""
|
111
|
-
|
112
|
-
Benchmark.bmbm do |x|
|
113
|
-
x.report("With Timber") { iterations.times { dispatch_rails_request("/") } }
|
114
|
-
end
|
115
|
-
|
116
|
-
puts "\n"
|
117
|
-
puts "Memory profiling via benchmark-memory:"
|
118
|
-
puts ""
|
119
|
-
|
120
|
-
Benchmark.memory do |x|
|
121
|
-
x.report("With Timber") { iterations.times { dispatch_rails_request("/") } }
|
122
|
-
end
|