presto-metrics 0.4.2 → 0.6.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/.github/release-drafter.yml +46 -0
- data/.github/workflows/publisher.yml +35 -0
- data/.github/workflows/release-drafter.yml +28 -0
- data/.github/workflows/ruby.yml +36 -0
- data/.gitignore +1 -2
- data/.standard.yml +8 -0
- data/.standard_todo.yml +25 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +92 -0
- data/lib/presto/metrics/client.rb +58 -61
- data/lib/presto/metrics/query.rb +12 -16
- data/lib/presto/metrics/version.rb +1 -1
- data/lib/presto/metrics.rb +3 -3
- data/presto-metrics.gemspec +8 -1
- data/spec/presto/metrics_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -2
- metadata +30 -10
- data/.travis.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 475432321a70930290783305021b5d9ae1b7320c37a59e9c4f2c7e1cf7bb2214
|
4
|
+
data.tar.gz: 5bf3a7b83a7002f1cc434ce67e2d12090a3fae7e69b1495a36a3225ea111d263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f9c43913d3eca40a7717607ba4f54bf7caab60271533cec7f1d14d121549bd96ca3eda18fc22c107f67f1ea4da98dc3398fe85c28e80d95666d57e6469b294
|
7
|
+
data.tar.gz: c6610e125b8d26e9f4423f68d0fe0bd6087f870dcf28ebbc6b2dc0253a1dfbfecd24b6bed4095627b5bb86b3f5eb370504346d86ce263162f7f6dcb368a2ec5f
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
name-template: 'v$RESOLVED_VERSION'
|
3
|
+
tag-template: 'v$RESOLVED_VERSION'
|
4
|
+
categories:
|
5
|
+
- title: '🚀 Features'
|
6
|
+
labels:
|
7
|
+
- 'feature'
|
8
|
+
- 'enhancement'
|
9
|
+
- title: '🐛 Bug Fixes'
|
10
|
+
labels:
|
11
|
+
- 'bug'
|
12
|
+
- title: '👋 Deprecated'
|
13
|
+
labels:
|
14
|
+
- 'deprecation'
|
15
|
+
- title: '⛓ Dependency Updates'
|
16
|
+
label:
|
17
|
+
- 'library-update'
|
18
|
+
- 'test-library-update'
|
19
|
+
- 'sbt-plugin-update'
|
20
|
+
- 'dependencies'
|
21
|
+
- title: '🛠 Internal Updates'
|
22
|
+
label:
|
23
|
+
- 'internal'
|
24
|
+
- 'kaizen'
|
25
|
+
- title: '📚 Docs'
|
26
|
+
labels:
|
27
|
+
- 'doc'
|
28
|
+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
29
|
+
|
30
|
+
template: |
|
31
|
+
## What's Changed
|
32
|
+
$CHANGES
|
33
|
+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
34
|
+
|
35
|
+
autolabeler:
|
36
|
+
- label: 'doc'
|
37
|
+
files:
|
38
|
+
- '*.md'
|
39
|
+
- '*.yaml'
|
40
|
+
- label: 'bug'
|
41
|
+
title:
|
42
|
+
- '/fix/i'
|
43
|
+
- label: 'deprecation'
|
44
|
+
title:
|
45
|
+
- '/deprecate/i'
|
46
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
name: Publish to RubyGems
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
tags:
|
7
|
+
- v*
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
id-token: write
|
11
|
+
contents: write
|
12
|
+
|
13
|
+
# see: https://guides.rubygems.org/trusted-publishing/adding-a-publisher/
|
14
|
+
jobs:
|
15
|
+
push:
|
16
|
+
name: Push gem to RubyGems.org
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
steps:
|
19
|
+
# Set up
|
20
|
+
- uses: actions/checkout@v4
|
21
|
+
with:
|
22
|
+
persist-credentials: false
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
bundler-cache: false
|
27
|
+
ruby-version: 3.2
|
28
|
+
- name: Install gem packages
|
29
|
+
run: |
|
30
|
+
gem install bundler
|
31
|
+
bundle config set frozen true
|
32
|
+
bundle install --jobs 4 --retry 3
|
33
|
+
|
34
|
+
# Release
|
35
|
+
- uses: rubygems/release-gem@v1
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
name: Release Drafter
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
pull_request:
|
9
|
+
# Only following types are handled by the action, but one can default to all as well
|
10
|
+
types: [opened, reopened, synchronize]
|
11
|
+
# pull_request_target event is required for autolabeler to support PRs from forks
|
12
|
+
pull_request_target:
|
13
|
+
types: [opened, reopened, synchronize]
|
14
|
+
|
15
|
+
permissions:
|
16
|
+
contents: read
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
update_release_draft:
|
20
|
+
permissions:
|
21
|
+
contents: write
|
22
|
+
pull-requests: write
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
steps:
|
25
|
+
# Drafts your next Release notes as Pull Requests are merged into "master"
|
26
|
+
- uses: release-drafter/release-drafter@v5
|
27
|
+
env:
|
28
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
name: unit tests
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
max-parallel: 3
|
12
|
+
matrix:
|
13
|
+
ruby-version:
|
14
|
+
- "3.2"
|
15
|
+
- "3.3"
|
16
|
+
- "3.4"
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v4
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
- name: Install gem packages
|
25
|
+
run: |
|
26
|
+
gem install bundler
|
27
|
+
bundle install --jobs 4 --retry 3
|
28
|
+
bundle exec gem dependency -R
|
29
|
+
|
30
|
+
- name: Check coding style
|
31
|
+
run: |
|
32
|
+
bundle exec standardrb
|
33
|
+
|
34
|
+
- name: test with Rake
|
35
|
+
run: |
|
36
|
+
bundle exec rake spec
|
data/.gitignore
CHANGED
data/.standard.yml
ADDED
data/.standard_todo.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
ignore:
|
3
|
+
- lib/presto/metrics/client.rb:
|
4
|
+
- Naming/VariableName
|
5
|
+
- Performance/RedundantSplitRegexpArgument
|
6
|
+
- Performance/StringReplacement
|
7
|
+
- Performance/UriDefaultParser
|
8
|
+
- Style/ClassCheck
|
9
|
+
- Style/ConditionalAssignment
|
10
|
+
- Style/EmptyLiteral
|
11
|
+
- Style/IfInsideElse
|
12
|
+
- Style/PercentLiteralDelimiters # Keep
|
13
|
+
- Style/RedundantBegin
|
14
|
+
- Style/StringLiterals
|
15
|
+
- Style/TrailingCommaInHashLiteral # Keep
|
16
|
+
- lib/presto/metrics/query.rb:
|
17
|
+
- Layout/ArgumentAlignment
|
18
|
+
- Layout/SpaceInsideArrayPercentLiteral # Keep
|
19
|
+
- Layout/SpaceInsidePercentLiteralDelimiters # Keep
|
20
|
+
- Naming/VariableName
|
21
|
+
- Style/ConditionalAssignment
|
22
|
+
- Style/MixinUsage
|
23
|
+
- Style/PercentLiteralDelimiters # Keep
|
24
|
+
- Style/RedundantBegin
|
25
|
+
- Style/StringLiterals
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
presto-metrics (0.6.0)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.3)
|
11
|
+
bigdecimal (3.2.2)
|
12
|
+
csv (3.3.5)
|
13
|
+
diff-lcs (1.6.2)
|
14
|
+
faraday (0.17.6)
|
15
|
+
multipart-post (>= 1.2, < 3)
|
16
|
+
httparty (0.23.1)
|
17
|
+
csv
|
18
|
+
mini_mime (>= 1.0.0)
|
19
|
+
multi_xml (>= 0.5.2)
|
20
|
+
httpclient (2.9.0)
|
21
|
+
mutex_m
|
22
|
+
json (2.13.2)
|
23
|
+
mini_mime (1.1.5)
|
24
|
+
msgpack (1.8.0)
|
25
|
+
multi_xml (0.7.2)
|
26
|
+
bigdecimal (~> 3.1)
|
27
|
+
multipart-post (2.4.1)
|
28
|
+
mutex_m (0.3.0)
|
29
|
+
parallel (1.27.0)
|
30
|
+
parser (3.3.9.0)
|
31
|
+
ast (~> 2.4.1)
|
32
|
+
racc
|
33
|
+
presto-client (0.5.14)
|
34
|
+
faraday (~> 0.12)
|
35
|
+
msgpack (>= 0.7.0)
|
36
|
+
prism (1.4.0)
|
37
|
+
racc (1.8.1)
|
38
|
+
rainbow (3.1.1)
|
39
|
+
rake (13.3.0)
|
40
|
+
regexp_parser (2.11.0)
|
41
|
+
rexml (3.4.1)
|
42
|
+
rspec (3.13.1)
|
43
|
+
rspec-core (~> 3.13.0)
|
44
|
+
rspec-expectations (~> 3.13.0)
|
45
|
+
rspec-mocks (~> 3.13.0)
|
46
|
+
rspec-core (3.13.5)
|
47
|
+
rspec-support (~> 3.13.0)
|
48
|
+
rspec-expectations (3.13.5)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.13.0)
|
51
|
+
rspec-mocks (3.13.5)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.13.0)
|
54
|
+
rspec-support (3.13.4)
|
55
|
+
rubocop (1.35.1)
|
56
|
+
json (~> 2.3)
|
57
|
+
parallel (~> 1.10)
|
58
|
+
parser (>= 3.1.2.1)
|
59
|
+
rainbow (>= 2.2.2, < 4.0)
|
60
|
+
regexp_parser (>= 1.8, < 3.0)
|
61
|
+
rexml (>= 3.2.5, < 4.0)
|
62
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
63
|
+
ruby-progressbar (~> 1.7)
|
64
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
65
|
+
rubocop-ast (1.46.0)
|
66
|
+
parser (>= 3.3.7.2)
|
67
|
+
prism (~> 1.4)
|
68
|
+
rubocop-performance (1.14.3)
|
69
|
+
rubocop (>= 1.7.0, < 2.0)
|
70
|
+
rubocop-ast (>= 0.4.0)
|
71
|
+
ruby-progressbar (1.13.0)
|
72
|
+
standard (1.16.1)
|
73
|
+
rubocop (= 1.35.1)
|
74
|
+
rubocop-performance (= 1.14.3)
|
75
|
+
unicode-display_width (2.6.0)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
x86_64-darwin-21
|
79
|
+
x86_64-darwin-23
|
80
|
+
x86_64-linux
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
bundler (~> 2.0)
|
84
|
+
httpclient
|
85
|
+
presto-client (~> 0.5.6)
|
86
|
+
presto-metrics!
|
87
|
+
rake (~> 13.0)
|
88
|
+
rspec
|
89
|
+
standard (~> 1.16.0)
|
90
|
+
|
91
|
+
BUNDLED WITH
|
92
|
+
2.6.2
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Presto
|
2
2
|
module Metrics
|
3
|
-
|
4
3
|
class Client
|
5
|
-
def initialize(opts={})
|
4
|
+
def initialize(opts = {})
|
6
5
|
require 'httparty'
|
7
6
|
require 'json'
|
8
7
|
require 'set'
|
@@ -20,22 +19,22 @@ module Presto
|
|
20
19
|
end
|
21
20
|
|
22
21
|
@@MBEAN_ALIAS = {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
'memory' => 'java.lang:type=Memory',
|
23
|
+
'gc_cms' => 'java.lang:type=GarbageCollector,name=ConcurrentMarkSweep',
|
24
|
+
'gc_parnew' => 'java.lang:type=GarbageCollector,name=ParNew',
|
25
|
+
'os' => 'java.lang:type=OperatingSystem',
|
26
|
+
'query_manager' => 'presto.execution:name=QueryManager',
|
27
|
+
'query_execution' => 'presto.execution:name=QueryExecution',
|
28
|
+
'split_scheduler_stats' => 'presto.execution.scheduler:name=SplitSchedulerStats',
|
29
|
+
'task_executor' => 'presto.execution.executor:name=TaskExecutor',
|
30
|
+
'task_manager' => 'presto.execution:name=TaskManager',
|
31
|
+
'memory_pool_general' => 'presto.memory:type=MemoryPool,name=general',
|
32
|
+
'memory_pool_reserved' => 'presto.memory:type=MemoryPool,name=reserved',
|
33
|
+
'cluster_memory_manager' => 'presto.memory:name=ClusterMemoryManager',
|
34
|
+
'cluster_memory_pool_general' => 'presto.memory:type=ClusterMemoryPool,name=general',
|
35
|
+
'cluster_memory_pool_reserved' => 'presto.memory:type=ClusterMemoryPool,name=reserved',
|
36
|
+
'discovery_node_manager' => 'presto.metadata:name=DiscoveryNodeManager',
|
37
|
+
'pause_meter' => 'io.airlift.stats:name=PauseMeter',
|
39
38
|
}
|
40
39
|
|
41
40
|
def path(path)
|
@@ -64,9 +63,9 @@ module Presto
|
|
64
63
|
value = json_obj.find { |e|
|
65
64
|
e.is_a?(Hash) && e['key'] == path[depth]
|
66
65
|
}
|
67
|
-
extract_path(value['value'], path, depth+1)
|
66
|
+
extract_path(value['value'], path, depth + 1)
|
68
67
|
else
|
69
|
-
extract_path(json_obj[path[depth]], path, depth+1)
|
68
|
+
extract_path(json_obj[path[depth]], path, depth + 1)
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
@@ -79,8 +78,9 @@ module Presto
|
|
79
78
|
JSON.parse(get_mbean_json(mbean))
|
80
79
|
end
|
81
80
|
|
82
|
-
def get(path, default='{}')
|
83
|
-
|
81
|
+
def get(path, default = '{}')
|
82
|
+
parser = URI::Parser.new
|
83
|
+
resp = HTTParty.get(parser.escape("#{@endpoint}#{path}"), headers: @headers)
|
84
84
|
if resp.code == 200
|
85
85
|
resp.body
|
86
86
|
else
|
@@ -92,7 +92,7 @@ module Presto
|
|
92
92
|
get("#{@mbean_path}/#{mbean}")
|
93
93
|
end
|
94
94
|
|
95
|
-
def get_query_json(path='', default='[]')
|
95
|
+
def get_query_json(path = '', default = '[]')
|
96
96
|
get("#{@query_path}/#{path}", default)
|
97
97
|
end
|
98
98
|
|
@@ -118,21 +118,21 @@ module Presto
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def underscore(str)
|
121
|
-
str.gsub(/::/, '/')
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
121
|
+
str.gsub(/::/, '/')
|
122
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
123
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
124
|
+
.gsub(/ +/, '_')
|
125
|
+
.tr('-', '_')
|
126
|
+
.downcase
|
127
127
|
end
|
128
128
|
|
129
|
-
def get_metrics(mbean, target_attr=[])
|
129
|
+
def get_metrics(mbean, target_attr = [])
|
130
130
|
kv = Hash.new
|
131
131
|
arr = target_attr.kind_of?(Array) ? target_attr : [target_attr]
|
132
132
|
c_target_attr = map_to_canonical_name(arr).to_set
|
133
133
|
get_attributes(mbean)
|
134
|
-
|
135
|
-
|
134
|
+
.reject { |attr| attr['name'].nil? || attr['value'].nil? }
|
135
|
+
.each { |attr|
|
136
136
|
c_name = to_canonical_name(attr['name'])
|
137
137
|
if c_target_attr.empty? || c_target_attr.include?(c_name)
|
138
138
|
key = @caml_case ? attr['name'] : underscore(attr['name'])
|
@@ -149,24 +149,24 @@ module Presto
|
|
149
149
|
def extract_value(v)
|
150
150
|
if v.is_a?(Hash)
|
151
151
|
if v.has_key?('key') && v.has_key?('value')
|
152
|
-
{sanitize_key(v['key']) => extract_value(v['value'])
|
152
|
+
{sanitize_key(v['key']) => extract_value(v['value'])}
|
153
153
|
else
|
154
|
-
v.each_with_object({}) {|(k1, v1), h2|
|
154
|
+
v.each_with_object({}) { |(k1, v1), h2|
|
155
155
|
h2[sanitize_key(k1)] = extract_value(v1)
|
156
156
|
}
|
157
157
|
end
|
158
|
-
elsif v.is_a?(Array) && v.all?{|e| e.is_a?(Hash) }
|
159
|
-
v.each_with_object({}){|e, h| h.merge!(extract_value(e)) }
|
158
|
+
elsif v.is_a?(Array) && v.all? { |e| e.is_a?(Hash) }
|
159
|
+
v.each_with_object({}) { |e, h| h.merge!(extract_value(e)) }
|
160
160
|
else
|
161
161
|
v
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
def get_gc_metrics(mbean, target_attr=[])
|
165
|
+
def get_gc_metrics(mbean, target_attr = [])
|
166
166
|
h = {}
|
167
167
|
get_attributes(mbean)
|
168
|
-
|
169
|
-
|
168
|
+
.reject { |attr| attr['name'].nil? || attr['value'].nil? }
|
169
|
+
.each { |attr|
|
170
170
|
key = sanitize_key(attr['name'])
|
171
171
|
v = attr['value']
|
172
172
|
h[key] = extract_value(v)
|
@@ -174,74 +174,72 @@ module Presto
|
|
174
174
|
h
|
175
175
|
end
|
176
176
|
|
177
|
-
|
178
|
-
def memory_usage_metrics(target_attr=[])
|
177
|
+
def memory_usage_metrics(target_attr = [])
|
179
178
|
get_metrics('java.lang:type=Memory', target_attr)
|
180
179
|
end
|
181
180
|
|
182
|
-
def gc_cms_metrics(target_attr=[])
|
181
|
+
def gc_cms_metrics(target_attr = [])
|
183
182
|
get_gc_metrics('java.lang:type=GarbageCollector,name=ConcurrentMarkSweep', target_attr)
|
184
183
|
end
|
185
184
|
|
186
|
-
def gc_parnew_metrics(target_attr=[])
|
185
|
+
def gc_parnew_metrics(target_attr = [])
|
187
186
|
get_gc_metrics('java.lang:type=GarbageCollector,name=ParNew', target_attr)
|
188
187
|
end
|
189
188
|
|
190
|
-
def gc_g1_metrics(target_attr=[])
|
191
|
-
['G1 Old Generation', 'G1 Young Generation'].each_with_object({}){|gen, h|
|
189
|
+
def gc_g1_metrics(target_attr = [])
|
190
|
+
['G1 Old Generation', 'G1 Young Generation'].each_with_object({}) { |gen, h|
|
192
191
|
h[sanitize_key(gen)] = get_gc_metrics("java.lang:type=GarbageCollector,name=#{gen}", target_attr)
|
193
192
|
}
|
194
193
|
end
|
195
194
|
|
196
|
-
def os_metrics(target_attr=[])
|
195
|
+
def os_metrics(target_attr = [])
|
197
196
|
get_metrics('java.lang:type=OperatingSystem', target_attr)
|
198
197
|
end
|
199
198
|
|
200
|
-
def query_manager_metrics(target_attr=[])
|
199
|
+
def query_manager_metrics(target_attr = [])
|
201
200
|
get_metrics('presto.execution:name=QueryManager', target_attr)
|
202
201
|
end
|
203
202
|
|
204
|
-
def query_execution_metrics(target_attr=[])
|
203
|
+
def query_execution_metrics(target_attr = [])
|
205
204
|
get_metrics('presto.execution:name=QueryExecution', target_attr)
|
206
205
|
end
|
207
206
|
|
208
|
-
def node_scheduler_metrics(target_attr=[])
|
207
|
+
def node_scheduler_metrics(target_attr = [])
|
209
208
|
get_metrics('presto.execution:name=NodeScheduler', target_attr)
|
210
209
|
end
|
211
210
|
|
212
|
-
def task_executor_metrics(target_attr=[])
|
211
|
+
def task_executor_metrics(target_attr = [])
|
213
212
|
get_metrics('presto.execution:name=TaskExecutor', target_attr)
|
214
213
|
end
|
215
214
|
|
216
|
-
def task_manager_metrics(target_attr=[])
|
215
|
+
def task_manager_metrics(target_attr = [])
|
217
216
|
get_metrics('presto.execution:name=TaskManager', target_attr)
|
218
217
|
end
|
219
218
|
|
220
|
-
def memory_pool_metrics(target_attr=[])
|
221
|
-
['general', 'reserved'].each_with_object({}) {|type, hash|
|
219
|
+
def memory_pool_metrics(target_attr = [])
|
220
|
+
['general', 'reserved'].each_with_object({}) { |type, hash|
|
222
221
|
hash[type] = get_metrics("presto.memory:type=MemoryPool,name=#{type}", target_attr)
|
223
222
|
}
|
224
223
|
end
|
225
224
|
|
226
|
-
def cluster_memory_pool_metrics(target_attr=[])
|
227
|
-
['general', 'reserved'].each_with_object({}) {|type, hash|
|
225
|
+
def cluster_memory_pool_metrics(target_attr = [])
|
226
|
+
['general', 'reserved'].each_with_object({}) { |type, hash|
|
228
227
|
hash[type] = get_metrics("presto.memory:type=ClusterMemoryPool,name=#{type}", target_attr)
|
229
228
|
}
|
230
229
|
end
|
231
230
|
|
232
|
-
def cluster_memory_manager_metrics(target_attr=[])
|
231
|
+
def cluster_memory_manager_metrics(target_attr = [])
|
233
232
|
get_metrics("presto.memory:name=ClusterMemoryManager", target_attr)
|
234
233
|
end
|
235
234
|
|
236
|
-
|
237
|
-
def node_metrics(target_attr=[])
|
235
|
+
def node_metrics(target_attr = [])
|
238
236
|
p = URI::Parser.new
|
239
237
|
node_state = JSON.parse(get_node_json)
|
240
|
-
node_state.map{|n|
|
238
|
+
node_state.map { |n|
|
241
239
|
uri = n['uri'] || ''
|
242
240
|
m = {}
|
243
241
|
m['host'] = p.parse(uri).host
|
244
|
-
n.each{|k, v|
|
242
|
+
n.each { |k, v|
|
245
243
|
key = @caml_case ? k : underscore(k)
|
246
244
|
m[key] = v
|
247
245
|
}
|
@@ -253,4 +251,3 @@ module Presto
|
|
253
251
|
end
|
254
252
|
end
|
255
253
|
end
|
256
|
-
|
data/lib/presto/metrics/query.rb
CHANGED
@@ -8,7 +8,6 @@ include Presto::Client::Models
|
|
8
8
|
|
9
9
|
module Presto
|
10
10
|
module Metrics
|
11
|
-
|
12
11
|
class Query
|
13
12
|
def initialize(client)
|
14
13
|
@client = client
|
@@ -38,12 +37,12 @@ module Presto
|
|
38
37
|
str = cell.to_s[0..col[i]]
|
39
38
|
a = align[i] || 'l'
|
40
39
|
case a
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
when 'r'
|
41
|
+
line << str.rjust(col[i])
|
42
|
+
when 'l'
|
43
|
+
line << str.ljust(col[i])
|
44
|
+
else
|
45
|
+
line << str.ljust(col[i])
|
47
46
|
end
|
48
47
|
}
|
49
48
|
puts line.join(sep)
|
@@ -62,8 +61,7 @@ module Presto
|
|
62
61
|
format_table(tbl,
|
63
62
|
%w|query time state r f t user catalog schema source sql|,
|
64
63
|
%w|r r r r r r l l r l l |,
|
65
|
-
' '
|
66
|
-
)
|
64
|
+
' ')
|
67
65
|
end
|
68
66
|
|
69
67
|
def find(queryId)
|
@@ -92,11 +90,10 @@ module Presto
|
|
92
90
|
format_table(stats,
|
93
91
|
%w|task_id host state processed_rows size|,
|
94
92
|
%w|l l l r r|,
|
95
|
-
' '
|
96
|
-
)
|
93
|
+
' ')
|
97
94
|
end
|
98
95
|
|
99
|
-
def query_list(path="")
|
96
|
+
def query_list(path = "")
|
100
97
|
begin
|
101
98
|
JSON.parse(@client.get_query_json(path))
|
102
99
|
rescue
|
@@ -154,9 +151,9 @@ module Presto
|
|
154
151
|
h['elapsed_time'] = stats['elapsedTime'] || '0.0m'
|
155
152
|
h['create_time'] = stats['createTime']
|
156
153
|
h['running_time'] = stats['endTime'] || Time.now.utc.iso8601(3) # end_time ?
|
157
|
-
#if(h['state'] == "FAILED")
|
154
|
+
# if(h['state'] == "FAILED")
|
158
155
|
# h['errorCode'] = find(h['query_id'])['errorCode'] || {}
|
159
|
-
#end
|
156
|
+
# end
|
160
157
|
h
|
161
158
|
}
|
162
159
|
end
|
@@ -169,9 +166,8 @@ module Presto
|
|
169
166
|
task_list << tl if tl
|
170
167
|
task_list << find_tasks(ss['subStages'])
|
171
168
|
}
|
172
|
-
task_list.flatten
|
169
|
+
task_list.flatten
|
173
170
|
end
|
174
|
-
|
175
171
|
end
|
176
172
|
end
|
177
173
|
end
|
data/lib/presto/metrics.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "presto/metrics/version"
|
2
|
+
require "presto/metrics/client"
|
3
|
+
require "presto/metrics/query"
|
data/presto-metrics.gemspec
CHANGED
@@ -18,11 +18,18 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.required_ruby_version = ">= 3.2.0"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 2.0"
|
22
|
-
spec.add_development_dependency "rake", "~>
|
24
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
23
25
|
spec.add_development_dependency "rspec"
|
24
26
|
spec.add_development_dependency "presto-client", '~> 0.5.6'
|
25
27
|
spec.add_development_dependency "httpclient"
|
28
|
+
spec.add_development_dependency "standard", ["~> 1.16.0"]
|
29
|
+
|
30
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4")
|
31
|
+
spec.add_dependency("base64")
|
32
|
+
end
|
26
33
|
|
27
34
|
spec.add_runtime_dependency "httparty"
|
28
35
|
|
data/spec/presto/metrics_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Presto::Metrics do
|
4
|
-
it
|
4
|
+
it "has a version number" do
|
5
5
|
expect(Presto::Metrics::VERSION).not_to be nil
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
expect(
|
8
|
+
it "does something useful" do
|
9
|
+
expect(true).to eq(true)
|
10
10
|
end
|
11
11
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path(
|
2
|
-
require
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
|
+
require "presto/metrics"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: presto-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taro L. Saito
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: standard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.16.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.16.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: httparty
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,10 +116,16 @@ executables: []
|
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
119
|
+
- ".github/release-drafter.yml"
|
120
|
+
- ".github/workflows/publisher.yml"
|
121
|
+
- ".github/workflows/release-drafter.yml"
|
122
|
+
- ".github/workflows/ruby.yml"
|
105
123
|
- ".gitignore"
|
106
124
|
- ".rspec"
|
107
|
-
- ".
|
125
|
+
- ".standard.yml"
|
126
|
+
- ".standard_todo.yml"
|
108
127
|
- Gemfile
|
128
|
+
- Gemfile.lock
|
109
129
|
- LICENSE.txt
|
110
130
|
- README.md
|
111
131
|
- Rakefile
|
@@ -120,7 +140,7 @@ homepage: https://github.com/xerial/presto-metrics
|
|
120
140
|
licenses:
|
121
141
|
- MIT
|
122
142
|
metadata: {}
|
123
|
-
post_install_message:
|
143
|
+
post_install_message:
|
124
144
|
rdoc_options: []
|
125
145
|
require_paths:
|
126
146
|
- lib
|
@@ -128,15 +148,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
148
|
requirements:
|
129
149
|
- - ">="
|
130
150
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
151
|
+
version: 3.2.0
|
132
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
153
|
requirements:
|
134
154
|
- - ">="
|
135
155
|
- !ruby/object:Gem::Version
|
136
156
|
version: '0'
|
137
157
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
-
signing_key:
|
158
|
+
rubygems_version: 3.4.19
|
159
|
+
signing_key:
|
140
160
|
specification_version: 4
|
141
161
|
summary: A library for collecting metrics of Presto, a distributed SQL engine
|
142
162
|
test_files:
|
data/.travis.yml
DELETED