presto-metrics 0.1.1 → 0.2.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 +2 -2
- data/lib/presto/metrics.rb +28 -6
- data/lib/presto/metrics/version.rb +1 -1
- data/presto-metrics.gemspec +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a2bf2d4c30bd55568e9b94d7f9fd1597303a8d3
|
4
|
+
data.tar.gz: 0f7c7864bacaa407c2c526d6f1d3ac3eb6e36c1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e944e66ed17d4a470e407d4c7078908f9d4f248ab739b138397a6eda7c4acb7788fb9b5cbf9f2d1327a26fd9cea5293dab6631b23af2000691aa361270752d46
|
7
|
+
data.tar.gz: e4558c716d9f80925f7892a8c2a19062f119575c8353e279653097fc542633d536240824d1e7332929eeccfd3f483c4acec40693988a1c2cdf10c09448d2a5a2
|
data/README.md
CHANGED
@@ -49,11 +49,11 @@ client.os_metrics([:system_load_average, :free_physical_memory_size])
|
|
49
49
|
|
50
50
|
# Path queries
|
51
51
|
client.path("os:physical_memory_size")
|
52
|
-
# => {"
|
52
|
+
# => {"free_physical_memory_size"=>55034294272}
|
53
53
|
|
54
54
|
# You can use comma-separated list of path queries
|
55
55
|
client.path("memory:heap_memory_usage.used,non_heap_memory_usage.used")
|
56
|
-
# => {"heap_memory_usage
|
56
|
+
# => {"heap_memory_usage/used"=>926714864, "non_heap_memory_usage/used"=>108948488}
|
57
57
|
|
58
58
|
|
59
59
|
# Retrieve standard metrics
|
data/lib/presto/metrics.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "presto/metrics/version"
|
2
2
|
require 'httparty'
|
3
3
|
require 'json'
|
4
|
-
require 'jsonpath'
|
5
4
|
|
6
5
|
module Presto
|
7
6
|
module Metrics
|
@@ -58,17 +57,36 @@ module Presto
|
|
58
57
|
c = path.split(/:/)
|
59
58
|
target = c[0]
|
60
59
|
mbean = @@MBEAN_ALIAS[target] || target
|
61
|
-
|
62
|
-
return
|
60
|
+
json_obj = get_metrics(mbean)
|
61
|
+
return json_obj if c.size <= 1
|
63
62
|
query_list = (c[1] || "").split(/,/)
|
64
63
|
result = {}
|
65
64
|
query_list.each{|q|
|
66
|
-
|
67
|
-
|
65
|
+
path_elems = q.split("/")
|
66
|
+
target_elem = extract_path(json_obj, path_elems, 0)
|
67
|
+
result[q] = target_elem unless target_elem.nil?
|
68
68
|
}
|
69
69
|
result
|
70
70
|
end
|
71
71
|
|
72
|
+
|
73
|
+
def extract_path(json_obj, path, depth)
|
74
|
+
return nil if json_obj.nil?
|
75
|
+
if depth >= path.length
|
76
|
+
json_obj
|
77
|
+
else
|
78
|
+
if json_obj.kind_of?(Array)
|
79
|
+
# Handle key, value pairs of GC information
|
80
|
+
value = json_obj.find{|e|
|
81
|
+
e.is_a?(Hash) && e['key'] == path[depth]
|
82
|
+
}
|
83
|
+
extract_path(value['value'], path, depth+1)
|
84
|
+
else
|
85
|
+
extract_path(json_obj[path[depth]], path, depth+1)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
72
90
|
def query
|
73
91
|
Query.new(self)
|
74
92
|
end
|
@@ -79,7 +97,11 @@ module Presto
|
|
79
97
|
|
80
98
|
def get(path)
|
81
99
|
resp = HTTParty.get("#{@endpoint}#{path}")
|
82
|
-
resp.
|
100
|
+
if resp.code == 200
|
101
|
+
resp.body
|
102
|
+
else
|
103
|
+
"{}"
|
104
|
+
end
|
83
105
|
end
|
84
106
|
|
85
107
|
def get_mbean_json(mbean)
|
data/presto-metrics.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: presto-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taro L. Saito
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: jsonpath
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
description: Monitoring Presto coordinator and worker processes through JMX REST API
|
84
70
|
(/v1/jmx/mbean)
|
85
71
|
email:
|