cabin 0.1.7 → 0.1.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.
data/examples/sinatra-logging.rb
CHANGED
data/lib/cabin/channel.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "cabin/namespace"
|
2
|
+
|
3
|
+
# What kind of metrics do we want?
|
4
|
+
# Per-call/transaction/request metrics like:
|
5
|
+
# - hit (count++ type metrics)
|
6
|
+
# - latencies/timings
|
7
|
+
#
|
8
|
+
# Per app or generally long-lifetime metrics like:
|
9
|
+
# - "uptime"
|
10
|
+
# - cpu usage
|
11
|
+
# - memory usage
|
12
|
+
# - count of active/in-flight actions/requests/calls/transactions
|
13
|
+
# - peer metrics (number of cluster members, etc)
|
14
|
+
module Cabin::Mixins::Metrics
|
15
|
+
|
16
|
+
end # module Cabin::Mixins::Metrics
|
data/lib/cabin/namespace.rb
CHANGED
@@ -6,24 +6,25 @@ require "eventmachine"
|
|
6
6
|
# allows you to output to a normal ruby logger with Cabin. Since
|
7
7
|
# Ruby's Logger has a love for strings alone, this wrapper will
|
8
8
|
# convert the data/event to json before sending it to Logger.
|
9
|
-
class Cabin::Outputs::
|
9
|
+
class Cabin::Outputs::EM::StdlibLogger
|
10
10
|
public
|
11
11
|
def initialize(logger)
|
12
12
|
@logger_queue = EM::Queue.new
|
13
13
|
@logger = logger
|
14
|
-
|
15
|
-
|
14
|
+
# Consume log lines from a queue and send them with logger
|
15
|
+
consumer
|
16
|
+
end
|
16
17
|
|
17
18
|
def consumer
|
18
19
|
line_sender = Proc.new do |line|
|
19
20
|
# This will call @logger.info(data) or something similar
|
20
21
|
@logger.send(line[:method], line[:message])
|
21
|
-
EM
|
22
|
-
#
|
22
|
+
EM::next_tick do
|
23
|
+
# Pop another line off the queue and do it again
|
23
24
|
@logger_queue.pop(&line_sender)
|
24
25
|
end
|
25
26
|
end
|
26
|
-
# Pop line off queue and send it with logger
|
27
|
+
# Pop a line off the queue and send it with logger
|
27
28
|
@logger_queue.pop(&line_sender)
|
28
29
|
end
|
29
30
|
|
@@ -33,7 +34,12 @@ class Cabin::Outputs::EmStdlibLogger
|
|
33
34
|
line = Hash.new
|
34
35
|
line[:method] = data[:level] || "info"
|
35
36
|
line[:message] = "#{data[:message]} #{data.to_json}"
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
if EM::reactor_running?
|
38
|
+
# Push line onto queue for later sending
|
39
|
+
@logger_queue.push(line)
|
40
|
+
else
|
41
|
+
# This will call @logger.info(data) or something similar
|
42
|
+
@logger.send(line[:method], line[:message])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,44 +1,54 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cabin
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 8
|
9
|
+
version: 0.1.8
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Jordan Sissel
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2012-01-13 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: json
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
22
31
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
consumable. Plain text logs are bullshit, let's emit structured and contextual logs.
|
27
|
-
email:
|
32
|
+
version_requirements: *id001
|
33
|
+
description: This is an experiment to try and make logging more flexible and more consumable. Plain text logs are bullshit, let's emit structured and contextual logs.
|
34
|
+
email:
|
28
35
|
- jls@semicomplete.com
|
29
|
-
executables:
|
36
|
+
executables:
|
30
37
|
- rubygems-cabin-test
|
31
38
|
extensions: []
|
39
|
+
|
32
40
|
extra_rdoc_files: []
|
33
|
-
|
41
|
+
|
42
|
+
files:
|
34
43
|
- lib/cabin.rb
|
35
|
-
- lib/cabin/outputs/em
|
44
|
+
- lib/cabin/outputs/em/stdlib-logger.rb
|
36
45
|
- lib/cabin/outputs/stdlib-logger.rb
|
37
46
|
- lib/cabin/channel.rb
|
38
47
|
- lib/cabin/namespace.rb
|
39
48
|
- lib/cabin/timer.rb
|
40
49
|
- lib/cabin/context.rb
|
41
50
|
- lib/cabin/mixins/dragons.rb
|
51
|
+
- lib/cabin/mixins/metrics.rb
|
42
52
|
- lib/cabin/mixins/logger.rb
|
43
53
|
- examples/fibonacci-timing.rb
|
44
54
|
- examples/sinatra-logging.rb
|
@@ -48,30 +58,38 @@ files:
|
|
48
58
|
- LICENSE
|
49
59
|
- CHANGELIST
|
50
60
|
- bin/rubygems-cabin-test
|
61
|
+
has_rdoc: true
|
51
62
|
homepage: https://github.com/jordansissel/ruby-cabin
|
52
|
-
licenses:
|
63
|
+
licenses:
|
53
64
|
- Apache License (2.0)
|
54
65
|
post_install_message:
|
55
66
|
rdoc_options: []
|
56
|
-
|
67
|
+
|
68
|
+
require_paths:
|
57
69
|
- lib
|
58
70
|
- lib
|
59
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
72
|
none: false
|
61
|
-
requirements:
|
62
|
-
- -
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
80
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
71
87
|
requirements: []
|
88
|
+
|
72
89
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.
|
90
|
+
rubygems_version: 1.3.7
|
74
91
|
signing_key:
|
75
92
|
specification_version: 3
|
76
93
|
summary: Experiments in structured and contextual logging
|
77
94
|
test_files: []
|
95
|
+
|