timber 1.0.7 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66f219592e109d976752d4334d0daf0008327a4d
4
- data.tar.gz: 95f2d9e28f713c6ebcd344860445235aa0799cdd
3
+ metadata.gz: 9e48b303535350b36a68d4af296da5a9ee1ddfe1
4
+ data.tar.gz: accd259a2827a8a466e5cb2aadfc93ac8d350cb9
5
5
  SHA512:
6
- metadata.gz: ed74f610fdc2758631f621d95adbd7c925b8573a4f870747a4423420dfb0ea2fdd8951e94516972ad8ccc9023bfa94ad7df14479c00fbb35f8abf47a3880dcff
7
- data.tar.gz: 80a086de1b57fca570db4508349f94d370dc850bab15e4ef090fe1c621580f9dab67d2fb503845f32432e42b657f9f0d8fee615d487809b057b7c826bf63b61f
6
+ metadata.gz: 2f4bf4cf69e07973acc22b59892bcb0b33c76af23de8023fa6fde65807752d7f2d5739ecbed720e0c344bf2c14eda2b994772ec0450fc36c40922d9681e65ea1
7
+ data.tar.gz: 5917a43860fe36328e1a5246596eca5124ce4a4ca589f41a7b1a3da529484c5b04fab5760f96e98d74f64e90a75b782b7188f2057aa6d2423705a9f03f151ed4
data/README.md CHANGED
@@ -58,9 +58,8 @@ Into this:
58
58
  }
59
59
  ```
60
60
 
61
- Notice we include data that isn't in the log message directly. It does the same for
62
- `http requests`, `sql queries`, `exceptions`, `template renderings`, and any other event
63
- your framework logs.
61
+ It does the same for `http requests`, `sql queries`, `exceptions`, `template renderings`,
62
+ and any other event your framework logs.
64
63
 
65
64
  (for a full list see [`Timber::Events`](lib/timber/events))
66
65
 
@@ -69,19 +68,13 @@ your framework logs.
69
68
 
70
69
  Glad you asked! :)
71
70
 
72
- 1. It's application aware and enriches your logs with data you can't get otherwise. This
73
- entire process is fully managed for you.
71
+ 1. It's application aware and enriches your logs with data you can't get otherwise.
74
72
  2. It defines a shared schema across all of our libraries. Meaning your log data, across all
75
- applications, will be normalized.
73
+ applications, is normalized.
76
74
  3. It does not alter the original log message, giving you the best of both worlds: human
77
75
  readable logs *and* rich structured events.
78
- 4. It's completely transparent with absolutely no vendor lock-in or risk of code debt. Timber
79
- adheres exactly to the `Logger` API. Meaning Timber can be installed and removed without
80
- any reprocusion.
81
-
82
- What really makes Timber unique is that at the end of the day it's just good ol' loggin'.
83
- No special API, no proprietary data format, the data is accessible and owned by you.
84
- [Woo!](http://i.giphy.com/7JYWGKgwxga5i.gif)
76
+ 4. It's completely transparent with absolutely no vendor lock-in or risk of code debt. It
77
+ does not introduce a special API, it's just good ol' loggin'.
85
78
 
86
79
 
87
80
  ## Logging Custom Events
@@ -113,8 +106,6 @@ No mention of Timber anywhere!
113
106
 
114
107
  ## The Timber Console / Pricing
115
108
 
116
- Like my mother always said:
117
-
118
109
  > What good is structured log data if you can't search and visualize it?
119
110
 
120
111
  Enter [the Timber Console](https://timber.io). It's a modern, fast, and beautiful console for
@@ -182,14 +173,8 @@ No probs! Use it as normal, Timber will even pull out the tags and include them
182
173
  config.logger = ActiveSupport::TaggedLogging.new(Timber::Logger.new(STDOUT))
183
174
  ```
184
175
 
185
- **Warning**: Tags lack meaningful descriptions, they are a poor mans context. Not to worry though!
186
- Timber provides a simple system for adding custom context that you can optionally use. Checkout
187
- [the `Timber::CurrentContext` docs](lib/timber/current_context.rb) for examples.
188
-
189
176
  ---
190
177
 
191
- I leave you with one final thought:
192
-
193
178
  <p align="center" style="background: #140f2a;">
194
179
  <a href="http://github.com/timberio/timber-ruby"><img src="http://files.timber.io/images/ruby-library-readme-log-truth.png" height="947" /></a>
195
180
  </p>
@@ -8,7 +8,7 @@ module Timber
8
8
  #
9
9
  # See {#initialize} for options and more details.
10
10
  class HTTP
11
- API_URI = URI.parse("https://logs.timber.io/frames")
11
+ API_URI = URI.parse(ENV["TIMBER_INGESTION_URL"] || "https://logs.timber.io/frames")
12
12
  CONTENT_TYPE = "application/x-timber-msgpack-frame-1".freeze
13
13
  CONNECTION_HEADER = "keep-alive".freeze
14
14
  USER_AGENT = "Timber Ruby Gem/#{Timber::VERSION}".freeze
@@ -16,6 +16,7 @@ module Timber
16
16
  https.use_ssl = true
17
17
  https.read_timeout = 30
18
18
  https.ssl_timeout = 10
19
+ # Ruby 1.9.X doesn't have this setting.
19
20
  if https.respond_to?(:keep_alive_timeout=)
20
21
  https.keep_alive_timeout = 60
21
22
  end
@@ -64,6 +65,15 @@ module Timber
64
65
  @delivery_interval_thread = Thread.new do
65
66
  loop do
66
67
  sleep(options[:delivery_frequency_seconds] || DELIVERY_FREQUENCY_SECONDS)
68
+
69
+ @last_messages_overflow_count = 0
70
+ messages_overflown_count = @buffer.messages_overflown_count
71
+ if messages_overflown_count >= @last_messages_overflow_count
72
+ difference = messages_overflown_count - @last_messages_overflow_count
73
+ @last_messages_overflow_count = messages_overflown_count
74
+ logger.warn("Timber HTTP buffer has overflown #{difference} times")
75
+ end
76
+
67
77
  buffer_for_delivery = @buffer.reserve
68
78
  if buffer_for_delivery
69
79
  deliver(buffer_for_delivery)
@@ -106,11 +116,13 @@ module Timber
106
116
  res = HTTPS.request(request)
107
117
  code = res.code.to_i
108
118
  if code < 200 || code >= 300
109
- Config.instance.logger.debug("Timber HTTP delivery failed - #{res.code}: #{res.body}")
110
- sleep((try_index + 1) * BACKOFF_RATE_SECONDS)
119
+ try = try_index + 1
120
+ logger.debug("Timber HTTP delivery failed, try #{try} - #{res.code}: #{res.body}")
121
+ sleep(try * BACKOFF_RATE_SECONDS)
111
122
  else
112
123
  @buffer.remove(body)
113
- Config.instance.logger.debug("Timber HTTP delivery successful - #{code}")
124
+ logger.debug("Timber HTTP delivery successful - #{code}")
125
+ logger.debug("Timber new buffer size - #{@buffer.total_bytesize}")
114
126
  break # exit the loop
115
127
  end
116
128
  end
@@ -120,6 +132,10 @@ module Timber
120
132
  def authorization_payload
121
133
  @authorization_payload ||= "Basic #{Base64.strict_encode64(@api_key).chomp}"
122
134
  end
135
+
136
+ def logger
137
+ Config.instance.logger
138
+ end
123
139
  end
124
140
  end
125
141
  end
@@ -15,12 +15,15 @@ module Timber
15
15
  DEFAULT_PAYLOAD_LIMIT_BYTES = 5_000_000 # 5mb, the Timber API will not accept messages larger than this
16
16
  DEFAULT_LIMIT_BYTES = 50_000_000 # 50mb
17
17
 
18
+ attr_reader :messages_overflown_count
19
+
18
20
  def initialize(options = {})
19
21
  @buffers = []
20
22
  @monitor = Monitor.new
21
23
  @payload_limit_bytes = options[:payload_limit_bytes] || DEFAULT_PAYLOAD_LIMIT_BYTES
22
24
  @limit_bytes = options[:limit_bytes] || DEFAULT_LIMIT_BYTES
23
25
  @overflow_handler = options[:overflow_handler]
26
+ @messages_overflown_count = 0
24
27
  end
25
28
 
26
29
  def write(msg)
@@ -59,20 +62,25 @@ module Timber
59
62
  end
60
63
  end
61
64
 
62
- private
63
- def total_bytesize
64
- @buffers.reduce(0) { |acc, buffer| acc + buffer.bytesize }
65
- end
65
+ def total_bytesize
66
+ @buffers.reduce(0) { |acc, buffer| acc + buffer.bytesize }
67
+ end
66
68
 
69
+ private
67
70
  def writable_buffer
68
71
  @buffers.find { |buffer| !buffer.frozen? }
69
72
  end
70
73
 
71
74
  def handle_overflow(msg)
75
+ @messages_overflown_count += 1
72
76
  if @overflow_handler
73
77
  @overflow_handler.call(msg)
74
78
  end
75
79
  end
80
+
81
+ def logger
82
+ Config.instance.logger
83
+ end
76
84
  end
77
85
  end
78
86
  end
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
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: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.