1
0
mirror of https://github.com/meineerde/rackstash.git synced 2026-01-01 11:49:38 +00:00

33 Commits

Author SHA1 Message Date
3078bccafd Pass the raw Buffer timestamp through the event Hash
This allows filters and finally the encoder to use this without having
to first convert the timestamp (back) to a more suitable format.
2017-08-24 23:07:17 +02:00
78466f9439 Set the Buffer's timestamp when setting a tag 2017-08-17 00:49:10 +02:00
ff50daf1eb Fix documentation for Buffer#tags and Buffer#fields 2017-08-17 00:48:47 +02:00
021dbc256b Flush silent Buffers by default
With the change to allow ading fields to the Buffer with a Logger
interface in the previous commit, we should also flush those Buffers
with fields set that way by default.
2017-08-17 00:34:47 +02:00
013d0f7d92 Auto-flush the buffer when adding fields using Logger#add
With this interface, the user adds fields the same way they would add
messages. The implicit assumption here is that the buffer is handled the
same way. Thus, if the current buffer is non-buffering, we will
automatically flush it to the sink and clear it, just the same way as we
would have done it for a message.
2017-08-17 00:34:47 +02:00
4baa1b97f6 Extract Buffer#auto_flush method
This method is responsible to automatically flish non-buffering Buffers
when there are messages added
2017-08-17 00:07:21 +02:00
cca00408e2 With allow_silent, also check the presence of an explicit timestamp for Buffer#pending? 2017-08-16 20:54:55 +02:00
d8300a125e Rename Buffer#allow_empty? to Buffer#allow_silent?
This new name better reflects what this option actually does: it allows
to flush a Buffer even if there were just added fields or tags. A tryely
empty Buffer, i.e., one which has neither added messages, fields, or
tags is never flushed.
2017-08-16 20:46:28 +02:00
2fbdf3c1f5 Don't create the @version fields in events by default
This field is only relevant when actually sending JSON to Logstash.
Other formats don't need it. It is thus more desireable to only include
this field in a specific logstash JSON encoder.
2017-08-14 13:27:20 +02:00
168e62b63c Remove useless newlines 2017-08-12 14:02:03 +02:00
0fa327bb3a Don't refer to methods not available on the current class in yard docs 2017-08-04 14:38:24 +02:00
3f8745e32c Move the responsiblity for creating the event hash to the Buffer
With this move, we can also optimize the sinplest case where there are
no fields or tags on the Buffer and no defines default_fields or
default_tags on the Sink. In that case, we don't need to merge them,
avoiding the creation of several unecessary objects on Buffer flush.
2017-08-04 00:53:36 +02:00
4438bf42bc Lazy instanciate tags and fields on a Buffer instance 2017-08-03 22:31:48 +02:00
4eb381a733 Move Logger#add_exception to the Buffer and forward from the Logger 2017-07-28 16:58:51 +02:00
cce94b70ed Explicitly require concurrent gem for Buffer class 2017-07-21 17:06:37 +02:00
720406b318 Implement the full Sink class
A single Sink is tied to a single Logger. It is responsible to:

* Create a log event from a Buffer on #write and send it to each of the
  flows independently.
* Forward all actions to all of the defined Flows.

The Sink provides access to all configured data of the Logger which is
used for persisting the Buffers.
2017-07-20 00:06:06 +02:00
7032cc6999 Do not mutate external time objects when getting UTC time 2017-07-19 13:37:38 +02:00
a4a6b248cf Use frozen string literals throughout the codebase in Ruby >= 2.3 2017-07-17 13:35:24 +02:00
2f33e10ba9 Clarify that Buffer#add_message also sets the timestamp 2017-07-14 11:05:19 +02:00
db8a5e50b5 Improve code documentation 2017-06-16 23:04:54 +02:00
4bbbf25ef8 Use a Concurrent::Array for storing messages in the Buffer
This ensures that we can still concurrently add messages without messing
with the internal Array.
2017-04-27 21:49:36 +02:00
7e452b630a Create new fields, tags and message objects on Buffer#clear
This helps in ensuring thread-safety when flushing unbuffered Buffers.
Previously, it was possibly for client code to still hold references to
fields on a flushed and cleared buffer, potentially resulting in
unintended side-effects if the client code was not aware that the buffer
was cleared.

By creating ompletely new object instances, existing references only
point to data from before the clear. This ensures a clean cut.
2017-04-06 23:09:16 +02:00
6958b8f509 Add Rubocop config and resolve most style issues 2017-02-16 22:47:17 +01:00
c260d9b154 Don't refer to the (non-existing yet) rack middleware in the docs 2017-02-05 21:21:32 +01:00
d78739d7d4 Improve documentation of Buffer and BufferStack 2017-02-04 01:02:38 +01:00
e842d5c771 Automatically flush and clear a non-buffering Buffer after adding a message 2017-02-03 19:06:39 +01:00
cb4cdadd95 Add Buffer#flush to flush the current Buffer to the Sink 2017-02-03 19:05:44 +01:00
95c8b8f8fb Pass the sink from the Logger to each individual Buffer 2017-02-03 18:43:34 +01:00
bfe4cc854a Add Rackstash::Buffer#buffering? flag
Generally, a non-buffering Buffer will eventually be flushed to the sink
after each logged message. This thus mostly resembles the way
traditional loggers work in Ruby. A buffering Buffer however holds log
messages, fields and tags for a longer time. Only at a specific time,
all log messages and stored fields will be flushed to the Sink as a
single log event. A common scope for such an event is a full request to
a Rack app.
2017-02-03 14:54:50 +01:00
5e37df77e5 Add Rackstash::Buffer#clear to clear all data in a buffer 2017-02-03 14:21:22 +01:00
8d2ea04c4f Set a timestamp on the Buffer 2017-02-03 00:28:45 +01:00
551b75c65d Add fields and tags to the Buffer
Each buffer instance can hold messages, fields and tags. These together
form the log event which will eventually be written to the log target.

By adding fields and tags, you can add highly details structured
information to your logs which allow to filter and analyze the logs
without having to parse complex multi-line logs.
2017-02-02 23:55:02 +01:00
3081b03db1 Add basic logger structure with early spikes
The Rackstash::Logger class will server as the public main entry point
for users. It will eventually implement the mostly complete interface of
Ruby's Logger.

The idea of Rackstash is the we will allow to buffer multiple log
messages allong with additional data until a combined log event is
eventually flushed to an underlying log target. This allows to keep
connected log messages and data as a single unit from the start without
having to painstakingly parse and connect these in later systems again.
2017-01-18 23:34:55 +01:00