l2meter 0.2.4 → 0.3.0
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 +4 -4
- data/README.md +15 -4
- data/lib/l2meter/emitter.rb +13 -1
- data/lib/l2meter/thread_safe.rb +1 -0
- data/lib/l2meter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8813cc61c6cf80054b1f532ac952b4a3a8e9bcc1
|
4
|
+
data.tar.gz: bc8267895efdd3544c3bd1309504e0bc2f5d3135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: befb44d3bb18e708a2c2172036efdb6863688e8cace9f7c94adc4c55b38621f9dfd7b5a5338654b2f35271a4b0265023ace125983c7cf0cb41632d9ea84664af
|
7
|
+
data.tar.gz: e32e10b222b91ae98390f4c730e20d12ce59b3912b3f3ea4105621278d2517aa7ee2f3b2668aa3d2f376228e4793f3168f1392d8e95d03cccbc07f84081567f0
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ In case the exception is raised inside the block, l2meter will report is like
|
|
40
40
|
so:
|
41
41
|
|
42
42
|
```ruby
|
43
|
-
Metrics.log :doing_work do # => doing-work
|
43
|
+
Metrics.log :doing_work do # => doing-work at=start
|
44
44
|
raise ArgumentError, \ #
|
45
45
|
"something is wrong" #
|
46
46
|
end # => doing-work at=exception exception=ArgumentError message="something is wrong" elapsed=1.2345s
|
@@ -107,12 +107,23 @@ L2meter also allows to append elapsed time to your log messages automatically.
|
|
107
107
|
```ruby
|
108
108
|
Metrics.with_elapsed do
|
109
109
|
do_work_step_1
|
110
|
-
log :step_1_done # => step-1-done elapsed=1.2345s
|
110
|
+
Metrics.log :step_1_done # => step-1-done elapsed=1.2345s
|
111
111
|
do_work_step_2
|
112
|
-
log :step_2_done # => step-2-done elapsed=2.3456s
|
112
|
+
Metrics.log :step_2_done # => step-2-done elapsed=2.3456s
|
113
113
|
end
|
114
114
|
```
|
115
115
|
|
116
|
+
There's also a way to batch several calls into a single log line:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
Metrics.batch do
|
120
|
+
Metrics.log foo: :bar
|
121
|
+
Metrics.unique :registeration, "user@example.com"
|
122
|
+
Metrics.count :thing, 10
|
123
|
+
Metrics.sample :other_thing, 20
|
124
|
+
end # => foo=bar unique#registration=user@example.com count#thing=10 sample#other-thing=20
|
125
|
+
```
|
126
|
+
|
116
127
|
### Configuration
|
117
128
|
|
118
129
|
L2meter supports configuration. Here's how you can configure things:
|
@@ -140,7 +151,7 @@ Metrics.log foo: :bar # => app-name=my-app-name foo-bar
|
|
140
151
|
Dynamic context is also supported:
|
141
152
|
|
142
153
|
```ruby
|
143
|
-
|
154
|
+
config.context do
|
144
155
|
{ request_id: CurrentContext.request_id }
|
145
156
|
end
|
146
157
|
```
|
data/lib/l2meter/emitter.rb
CHANGED
@@ -69,6 +69,13 @@ module L2meter
|
|
69
69
|
self.class.new(configuration: configuration)
|
70
70
|
end
|
71
71
|
|
72
|
+
def batch
|
73
|
+
@outputs.push StringIO.new
|
74
|
+
yield
|
75
|
+
ensure
|
76
|
+
emit @outputs.pop.tap(&:rewind).read.split(/\s+/).uniq.join(" ")
|
77
|
+
end
|
78
|
+
|
72
79
|
private
|
73
80
|
|
74
81
|
def transform_log_args(*args)
|
@@ -122,9 +129,14 @@ module L2meter
|
|
122
129
|
|
123
130
|
tokens.sort! if configuration.sort?
|
124
131
|
|
125
|
-
|
132
|
+
emit tokens.join(" ")
|
126
133
|
end
|
127
134
|
|
135
|
+
def emit(text)
|
136
|
+
output_queue.last.puts text
|
137
|
+
end
|
138
|
+
|
139
|
+
|
128
140
|
def log_with_prefix(method, key, value, unit: nil)
|
129
141
|
key = [configuration.prefix, key, unit].compact * ?.
|
130
142
|
log Hash["#{method}##{key}", value]
|
data/lib/l2meter/thread_safe.rb
CHANGED
data/lib/l2meter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: l2meter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pravosud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
47
|
rubyforge_project:
|
48
|
-
rubygems_version: 2.
|
48
|
+
rubygems_version: 2.4.8
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: L2met friendly log formatter
|