liquid-ext 3.4.2 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ab68e51c9209484d0aa966b8498578a715ebba1
4
- data.tar.gz: 13123b71496c35456f68419ac5868a06a730c1fe
3
+ metadata.gz: f1eb7c79616fa8b96ebb46d0dbff36b696b54896
4
+ data.tar.gz: bf5333639d97bf2c6b7842d0d3cff015cac441af
5
5
  SHA512:
6
- metadata.gz: 6ff8cddc75aef8e7e262451341db272c9e7fe2cf0003bead9d8cedb9247cef145b42d4513ebee0615b01461e06e5d0a9108b546b7003e0f5563f57fb0994ad2a
7
- data.tar.gz: 8ca4dcdf20fdf87b1aa0714f5253e4f5f89a69b76a0219e3d670b983ddff16625be2fb49cb3b5ce46129e1dbb37cd538bba40007a21332bad442466581cac8e9
6
+ metadata.gz: 6ed90f105bc6ae3888833d2f03a3161ff639d46715a41cf4b54a71a322decdd3c5f90f369f4e3b76563051d6551f3c0c99a543108d2eedf042f6802161d1d6f8
7
+ data.tar.gz: a0ee19cd66b5906d89d50fb4437fd42db27084be22b8f5fa98633d6237b718ea11550f2d41360da11691309168917d910193d83b274b62596bb74bb00897ff60
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liquid-ext (3.4.2)
4
+ liquid-ext (3.5.0)
5
5
  activesupport
6
6
  erubis
7
7
  jmx4r
@@ -57,7 +57,7 @@ GEM
57
57
  method_source (0.8.2)
58
58
  minitest (5.3.4)
59
59
  mixlib-cli (1.5.0)
60
- multi_json (1.10.0)
60
+ multi_json (1.10.1)
61
61
  nokogiri (1.6.2.1-java)
62
62
  parallel (1.0.0)
63
63
  pry (0.9.12.6-java)
@@ -87,6 +87,9 @@ $conf.mixin({
87
87
  level: :info,
88
88
  format: "%d{ISO8601} %-5p #{File.basename($0)}(#{Process.pid})[%t]: %m%n",
89
89
  },
90
+ metrics: {
91
+ interval: 60,
92
+ },
90
93
  tracker: {
91
94
  dimensions: {},
92
95
  kafka: {
@@ -106,7 +106,7 @@ module Liquid
106
106
 
107
107
  value = Section.from_hash(value)
108
108
 
109
- deep_merge!(value[:generic]) if value.has_key?(:generic)
109
+ deep_merge!(value.delete(:generic)) if value.has_key?(:generic)
110
110
 
111
111
  if value.has_key?(Env.to_sym)
112
112
  deep_merge!(value[Env.to_sym])
@@ -16,7 +16,7 @@ class HealthCheck
16
16
  end
17
17
 
18
18
  def to_s
19
- "Result{isHealthy=#{healthy?},message=#{message.inspect},exception=#{exception.inspect}}"
19
+ "Result(healthy=#{healthy?},message=#{message.inspect},exception=#{exception.inspect})"
20
20
  end
21
21
  end
22
22
 
@@ -1,4 +1,5 @@
1
1
  if RUBY_PLATFORM == "java"
2
+ java_import 'com.codahale.metrics.Gauge'
2
3
  java_import 'com.codahale.metrics.Histogram'
3
4
  java_import 'com.codahale.metrics.JmxReporter'
4
5
  java_import 'com.codahale.metrics.MetricRegistry'
@@ -12,9 +13,9 @@ if RUBY_PLATFORM == "java"
12
13
  @registry = MetricRegistry.new
13
14
  @reporters = []
14
15
 
15
- def self.start(period = nil, unit = nil)
16
- @period ||= 60
17
- @unit ||= TimeUnit::SECONDS
16
+ def self.start
17
+ @period = $conf.metrics.interval
18
+ @unit = TimeUnit::SECONDS
18
19
  JmxReporter.forRegistry(@registry).build.start
19
20
  Signal.register_shutdown_handler { stop }
20
21
  end
@@ -36,6 +37,10 @@ if RUBY_PLATFORM == "java"
36
37
  @registry
37
38
  end
38
39
 
40
+ def self.gauge(name, handler)
41
+ registry.register(name, handler)
42
+ end
43
+
39
44
  def self.counter(name)
40
45
  registry.counter(name)
41
46
  end
@@ -84,7 +84,7 @@ module Metrics
84
84
  timestamp: Time.now.to_i,
85
85
  type: :gauge,
86
86
  name: name,
87
- value: gauge.value,
87
+ value: gauge.getValue,
88
88
  }
89
89
  end
90
90
 
@@ -4,9 +4,16 @@ if RUBY_PLATFORM == "java"
4
4
 
5
5
  module Liquid
6
6
  class Server
7
+ attr_reader :started_at
8
+
9
+ def name
10
+ @name ||= self.class.name.downcase.gsub(/::/, '.')
11
+ end
12
+
7
13
  def initialize
8
- $log.info("#{self.class.name.downcase} #{RUBY_DESCRIPTION}")
9
- $log.info("#{self.class.name.downcase}", env: Env.mode)
14
+ @started_at = Time.now
15
+ $log.info("#{name} #{RUBY_DESCRIPTION}")
16
+ $log.info("#{name}", env: Env.mode)
10
17
  Signal.register_shutdown_handler { System.exit(0) }
11
18
  Signal.register_shutdown_handler { ZContext.destroy }
12
19
  initialize_raven
@@ -41,9 +48,31 @@ if RUBY_PLATFORM == "java"
41
48
  Signal.register_shutdown_handler { $tracker.shutdown }
42
49
  end
43
50
 
51
+ class HealthGauge
52
+ include Gauge
53
+
54
+ def getValue
55
+ HealthCheck.healthy? ? 1 : 0
56
+ end
57
+ end
58
+
59
+ class UptimeGauge
60
+ include Gauge
61
+
62
+ def initialize(server)
63
+ @server = server
64
+ end
65
+
66
+ def getValue
67
+ @server.uptime.to_i
68
+ end
69
+ end
70
+
44
71
  def initialize_metrics
45
72
  ::Metrics.start
46
73
  ::Metrics::TrackerReporter.new($tracker.with_topic('metrics'))
74
+ ::Metrics.gauge("#{name}.healthy", HealthGauge.new)
75
+ ::Metrics.gauge("#{name}.uptime", UptimeGauge.new(self))
47
76
  Signal.register_shutdown_handler { ::Metrics.stop }
48
77
  end
49
78
 
@@ -67,6 +96,10 @@ if RUBY_PLATFORM == "java"
67
96
  Thread.join
68
97
  end
69
98
 
99
+ def uptime
100
+ Time.now - @started_at
101
+ end
102
+
70
103
  end
71
104
  end
72
105
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "liquid-ext"
5
- spec.version = "3.4.2"
5
+ spec.version = "3.5.0"
6
6
  spec.authors = ["LiquidM, Inc."]
7
7
  spec.email = ["opensource@liquidm.com"]
8
8
  spec.description = %q{Ruby core extensions and helper libraries}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LiquidM, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport