presto-metrics 0.3.9 → 0.3.10

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: a3c3d3f74169faa3e4cae0abe8eeb502faea7585
4
- data.tar.gz: f2284da30958c56c7c23924379b159660a4c9e23
3
+ metadata.gz: 76738b2193dac8ff0c1b85ab37c8d3773e7c1540
4
+ data.tar.gz: 024bef2488910dca9483240bc6fca29fe9d24c8d
5
5
  SHA512:
6
- metadata.gz: 8fafeb893d3f45120d0ad23a27359be2df3ebdc74d1dbe982c2f5a97c04c0ac43868032ee499e0ac29e4ba66f0b819d8e140544c4e1348ea4c66f889d7871643
7
- data.tar.gz: eba6f37b29ccc3f3e2eca0967c28ec70d4b25a3c2cf3aab8f78dbc5d9eb89fc2e76934ca5c5dcdec0bf444dd6091f84e9f4dc4a3ad6e62dc0f529f8edc903284
6
+ metadata.gz: 24cd82ee453475715789b9469458514d380b6f6027c9db7e912a60b18e0cb24b63df74da2700e85db2abfe08f73229bc10627ff35a2dd00913ec1d76e15fbaaf
7
+ data.tar.gz: 1deb4275a340a4162bf0a9111b6723acb1cfe949c179631b34f79bde31d8fa3df63863f88bd70d2524f73f6d879685636935738676f48454de0a5a3ed627dd31
data/README.md CHANGED
@@ -66,17 +66,15 @@ client.query_execution_metrics # com.facebook.presto.execution:name=QueryExecu
66
66
  client.node_scheduler_metrics # com.facebook.presto.execution:name=NodeScheduler
67
67
  client.task_executor_metrics # com.facebook.presto.execution:name=TaskExecutor
68
68
  client.task_manager_metrics # com.facebook.presto.execution:name=TaskManager
69
-
69
+ client.cluster_memory_manager_metrics # com.facebook.presto.memory:name=ClusterMemoryManager
70
70
 
71
71
  # Memory resource manager metrics (since Presto 0.103)
72
- ```ruby
73
72
  client.memory_pool_metrics
74
73
  => {"general"=>{"free_bytes"=>59700045415, "max_bytes"=>59700045415}, "reserved"=>{"free_bytes"=>2147483648, "max_bytes"=>2147483648}}
75
74
 
76
75
  client.cluster_memory_pool_metrics
77
76
  => {"general"=>{"blocked_nodes"=>0, "free_distributed_bytes"=>116833832981, "nodes"=>4, "queries"=>8, "total_distributed_bytes"=>131855495989},
78
77
  "reserved"=>{"blocked_nodes"=>0, "free_distributed_bytes"=>15032385536, "nodes"=>4, "queries"=>0, "total_distributed_bytes"=>15032385536}}
79
- ```
80
78
 
81
79
 
82
80
  # Retrieve presto worker metrics
@@ -102,6 +100,107 @@ pp client.node_metrics
102
100
  "age"=>"38.56m",
103
101
  "recent_failures_by_type"=>{}}]
104
102
 
103
+ # Garbage Collection metrics
104
+ pp client.gc_g1_metrics
105
+ {"g1_old_generation"=>
106
+ {"last_gc_info"=>
107
+ {"gc_thread_count"=>28,
108
+ "duration"=>478,
109
+ "end_time"=>9530,
110
+ "id"=>3,
111
+ "memory_usage_after_gc"=>
112
+ {"g1_survivor_space"=>{"committed"=>0, "init"=>0, "max"=>-1, "used"=>0},
113
+ "metaspace"=>
114
+ {"committed"=>60444672, "init"=>0, "max"=>-1, "used"=>56490104},
115
+ "g1_old_gen"=>
116
+ {"committed"=>134217728,
117
+ "init"=>1895825408,
118
+ "max"=>103079215104,
119
+ "used"=>75768752},
120
+ "g1_eden_space"=>
121
+ {"committed"=>134217728, "init"=>117440512, "max"=>-1, "used"=>0},
122
+ "code_cache"=>
123
+ {"committed"=>28114944,
124
+ "init"=>2555904,
125
+ "max"=>314572800,
126
+ "used"=>27676416}},
127
+ "memory_usage_before_gc"=>
128
+ {"g1_survivor_space"=>
129
+ {"committed"=>33554432, "init"=>0, "max"=>-1, "used"=>33554432},
130
+ "metaspace"=>
131
+ {"committed"=>60444672, "init"=>0, "max"=>-1, "used"=>56829560},
132
+ "g1_old_gen"=>
133
+ {"committed"=>234881024,
134
+ "init"=>1895825408,
135
+ "max"=>103079215104,
136
+ "used"=>10082520},
137
+ "g1_eden_space"=>
138
+ {"committed"=>402653184,
139
+ "init"=>117440512,
140
+ "max"=>-1,
141
+ "used"=>318767104},
142
+ "code_cache"=>
143
+ {"committed"=>28114944,
144
+ "init"=>2555904,
145
+ "max"=>314572800,
146
+ "used"=>27676416}},
147
+ "start_time"=>9052},
148
+ "collection_count"=>3,
149
+ "collection_time"=>1624,
150
+ "memory_pool_names"=>["G1 Eden Space", "G1 Survivor Space", "G1 Old Gen"],
151
+ "valid"=>true,
152
+ "name"=>"G1 Old Generation",
153
+ "object_name"=>"java.lang:type=GarbageCollector,name=G1 Old Generation"},
154
+ "g1_young_generation"=>
155
+ {"last_gc_info"=>
156
+ {"gc_thread_count"=>28,
157
+ "duration"=>26,
158
+ "end_time"=>7034504,
159
+ "id"=>145,
160
+ "memory_usage_after_gc"=>
161
+ {"g1_survivor_space"=>
162
+ {"committed"=>100663296, "init"=>0, "max"=>-1, "used"=>100663296},
163
+ "metaspace"=>
164
+ {"committed"=>73138176, "init"=>0, "max"=>-1, "used"=>67016896},
165
+ "g1_old_gen"=>
166
+ {"committed"=>5989466112,
167
+ "init"=>1895825408,
168
+ "max"=>103079215104,
169
+ "used"=>3212283664},
170
+ "g1_eden_space"=>
171
+ {"committed"=>9512681472, "init"=>117440512, "max"=>-1, "used"=>0},
172
+ "code_cache"=>
173
+ {"committed"=>63045632,
174
+ "init"=>2555904,
175
+ "max"=>314572800,
176
+ "used"=>62560832}},
177
+ "memory_usage_before_gc"=>
178
+ {"g1_survivor_space"=>
179
+ {"committed"=>83886080, "init"=>0, "max"=>-1, "used"=>83886080},
180
+ "metaspace"=>
181
+ {"committed"=>73138176, "init"=>0, "max"=>-1, "used"=>67016896},
182
+ "g1_old_gen"=>
183
+ {"committed"=>5771362304,
184
+ "init"=>1895825408,
185
+ "max"=>103079215104,
186
+ "used"=>3206420472},
187
+ "g1_eden_space"=>
188
+ {"committed"=>9747562496,
189
+ "init"=>117440512,
190
+ "max"=>-1,
191
+ "used"=>9277800448},
192
+ "code_cache"=>
193
+ {"committed"=>63045632,
194
+ "init"=>2555904,
195
+ "max"=>314572800,
196
+ "used"=>62560832}},
197
+ "start_time"=>7034478},
198
+ "collection_count"=>145,
199
+ "collection_time"=>8946,
200
+ "memory_pool_names"=>["G1 Eden Space", "G1 Survivor Space"],
201
+ "valid"=>true,
202
+ "name"=>"G1 Young Generation",
203
+ "object_name"=>"java.lang:type=GarbageCollector,name=G1 Young Generation"}}
105
204
 
106
205
  # Retrieve the JSON representation of JMX properties
107
206
  client.get_mbean_json("java.lang:Type=Memory")
@@ -9,69 +9,69 @@ include Presto::Client::Models
9
9
  module Presto
10
10
  module Metrics
11
11
 
12
- class Query
13
- def initialize(client)
14
- @client = client
15
- end
16
-
17
- def format_table(tbl, label, align, sep)
18
- # Compute col length
19
- col = {}
20
- label.each_with_index{|l, i| col[i] = l.length}
21
- tbl.each{|row|
22
- row.each_with_index {|cell, i|
23
- l = cell.to_s.size if cell
24
- l ||= 0
25
- col[i] ||= l
26
- col[i] = [[col[i], l].max, 150].min
27
- }
28
- }
29
- # print label
30
- line = []
31
- label.each_with_index{|l, i|
32
- line << l.to_s[0..col[i]].ljust(col[i])
33
- }
34
- puts line.join(sep)
35
- tbl.each{|row|
36
- line = []
37
- row.each_with_index{|cell, i|
38
- str = cell.to_s[0..col[i]]
39
- a = align[i] || 'l'
40
- case a
41
- when 'r'
42
- line << str.rjust(col[i])
43
- when 'l'
44
- line << str.ljust(col[i])
45
- else
46
- line << str.ljust(col[i])
47
- end
48
- }
49
- puts line.join(sep)
50
- }
51
- 0
52
- end
53
-
54
- def list
55
- ql = query_list
56
- tbl = ql.map {|q|
57
- s = q['session'] || {}
58
- query = q['query'].gsub(/[\t\r\n]/, ' ').gsub(/ {1,}/, ' ').strip
59
- [q['queryId'], q['elapsedTime'], q['state'], q['runningDrivers'], q['completedDrivers'], q['totalDrivers'], s['user'], s['catalog'], s['schema'], s['source'], query]
60
- }.sort_by{|row| row[0]}.reverse
61
-
62
- format_table(tbl,
63
- %w|query time state r f t user catalog schema source sql|,
64
- %w|r r r r r r l l r l l |,
65
- ' '
66
- )
67
- end
68
-
69
- def find(queryId)
70
- JSON.parse(@client.get_query_json(queryId, "{}"))
71
- end
72
-
73
- def task_list(queryId)
74
- qj = find(queryId) || {}
12
+ class Query
13
+ def initialize(client)
14
+ @client = client
15
+ end
16
+
17
+ def format_table(tbl, label, align, sep)
18
+ # Compute col length
19
+ col = {}
20
+ label.each_with_index { |l, i| col[i] = l.length }
21
+ tbl.each { |row|
22
+ row.each_with_index { |cell, i|
23
+ l = cell.to_s.size if cell
24
+ l ||= 0
25
+ col[i] ||= l
26
+ col[i] = [[col[i], l].max, 150].min
27
+ }
28
+ }
29
+ # print label
30
+ line = []
31
+ label.each_with_index { |l, i|
32
+ line << l.to_s[0..col[i]].ljust(col[i])
33
+ }
34
+ puts line.join(sep)
35
+ tbl.each { |row|
36
+ line = []
37
+ row.each_with_index { |cell, i|
38
+ str = cell.to_s[0..col[i]]
39
+ a = align[i] || 'l'
40
+ case a
41
+ when 'r'
42
+ line << str.rjust(col[i])
43
+ when 'l'
44
+ line << str.ljust(col[i])
45
+ else
46
+ line << str.ljust(col[i])
47
+ end
48
+ }
49
+ puts line.join(sep)
50
+ }
51
+ 0
52
+ end
53
+
54
+ def list
55
+ ql = query_list
56
+ tbl = ql.map { |q|
57
+ s = q['session'] || {}
58
+ query = q['query'].gsub(/[\t\r\n]/, ' ').gsub(/ {1,}/, ' ').strip
59
+ [q['queryId'], q['elapsedTime'], q['state'], q['runningDrivers'], q['completedDrivers'], q['totalDrivers'], s['user'], s['catalog'], s['schema'], s['source'], query]
60
+ }.sort_by { |row| row[0] }.reverse
61
+
62
+ format_table(tbl,
63
+ %w|query time state r f t user catalog schema source sql|,
64
+ %w|r r r r r r l l r l l |,
65
+ ' '
66
+ )
67
+ end
68
+
69
+ def find(queryId)
70
+ JSON.parse(@client.get_query_json(queryId, "{}"))
71
+ end
72
+
73
+ def task_list(queryId)
74
+ qj = find(queryId) || {}
75
75
  root_stage = qj['outputStage'] || {}
76
76
  tasks = root_stage['tasks'] || []
77
77
  tasks << find_tasks(root_stage['subStages'] || [])
@@ -80,87 +80,83 @@ module Presto
80
80
 
81
81
  def tasks(queryId)
82
82
  tl = task_list(queryId)
83
- stats = tl.map {|t|
83
+ stats = tl.map { |t|
84
84
  s = t['stats']
85
85
  host = (t['self'] || '').sub(/http:\/\/([a-z0-9\-.]+[\/:][0-9]+)\/.*/, '\1')
86
86
  [t['taskId'], host, t['state'], s['rawInputPositions'], s['rawInputDataSize'], s['queuedDrivers'], s['runningDrivers'], s['completedDrivers']]
87
87
  }
88
88
  format_table(stats,
89
- %w|task_id host state processed_rows size|,
90
- %w|l l l r r|,
91
- ' '
89
+ %w|task_id host state processed_rows size|,
90
+ %w|l l l r r|,
91
+ ' '
92
92
  )
93
93
  end
94
94
 
95
- def query_list(path="")
96
- JSON.parse(@client.get_query_json(path))
97
- end
95
+ def query_list(path="")
96
+ JSON.parse(@client.get_query_json(path))
97
+ end
98
98
 
99
99
  def running_list
100
- ql = query_list.select{|q| q['state'] == 'RUNNING'}.sort_by{|row| row[0]}.reverse
101
- ql.each{|q|
100
+ ql = query_list.select { |q| q['state'] == 'RUNNING' }.sort_by { |row| row[0] }.reverse
101
+ ql.each { |q|
102
102
  tasks(q['queryId'])
103
103
  }
104
104
  ql.size
105
- end
106
-
107
-
108
- def count_total_processed_rows(stage)
109
- return 0 unless stage
110
- rows = (stage.tasks || []).map{|t| t.stats.raw_input_positions }.inject(0, :+)
111
- rows + (stage.sub_stages || []).map{|ss| count_total_processed_rows(ss) }.inject(0, :+)
112
- end
113
-
114
- def processed_rows(query_id)
115
- qi = QueryInfo.decode(find(query_id))
116
- count_total_processed_rows(qi.output_stage)
117
- end
118
-
119
- def query_progress
120
- running_queries = query_list.map{|q| QueryInfo.decode(q) }.select{|q| q.state == :running }
121
- query_info = running_queries.map{|q|
122
- queryInfo = find(q.query_id)
123
- QueryInfo.decode(queryInfo)
124
- }
125
-
126
- result = {}
127
- query_info.each{|q|
128
- os = q.output_stage
129
- result[q.query_id] = count_total_processed_rows(os)
130
- }
131
- result
132
- end
133
-
134
- def metrics
135
- ql = query_list
136
- ql.map{|qi|
137
- h = {}
138
- h['query_id'] = qi['queryId'] || ''
139
- h['state'] = qi['state'] || ''
140
- session = qi['session'] || {}
141
- h['source'] = session['source'] || ''
142
- h['user'] = session['user'] || h['source'].gsub(/[^a-zA-Z0-9]/,'')
143
- h['running_drivers'] = qi['runningDrivers'] || 0
144
- h['queued_drivers'] = qi['queuedDrivers'] || 0
145
- h['completed_drivers'] = qi['completedDrivers'] || 0
146
- h['total_drivers'] = qi['totalDrivers'] || 0
147
- h['elapsed_time'] = qi['elapsedTime'] || '0.0m'
148
- h['create_time'] = qi['createTime']
149
- h['running_time'] = qi['endTime'] || Time.now.utc.iso8601(3)
150
- #if(h['state'] == "FAILED")
151
- # h['errorCode'] = find(h['query_id'])['errorCode'] || {}
152
- #end
153
- h
154
- }
155
105
  end
156
106
 
107
+ def count_total_processed_rows(stage)
108
+ return 0 unless stage
109
+ rows = stage.stage_stats.raw_input_positions + stage.stage_stats.output_positions
110
+ rows + (stage.sub_stages || []).map { |ss| count_total_processed_rows(ss) }.inject(0, :+)
111
+ end
112
+
113
+ def processed_rows(query_id)
114
+ qi = QueryInfo.decode(find(query_id))
115
+ count_total_processed_rows(qi.output_stage)
116
+ end
157
117
 
118
+ def query_progress
119
+ running_queries = query_list.map { |q| QueryInfo.decode(q) }.select { |q| q.state == :running }
120
+ query_info = running_queries.map { |q|
121
+ queryInfo = find(q.query_id)
122
+ QueryInfo.decode(queryInfo)
123
+ }
158
124
 
125
+ result = {}
126
+ query_info.each { |q|
127
+ os = q.output_stage
128
+ result[q.query_id] = count_total_processed_rows(os)
129
+ }
130
+ result
131
+ end
132
+
133
+ def metrics
134
+ ql = query_list
135
+ ql.map { |qi|
136
+ h = {}
137
+ h['query_id'] = qi['queryId'] || ''
138
+ h['state'] = qi['state'] || ''
139
+ session = qi['session'] || {}
140
+ h['source'] = session['source'] || ''
141
+ h['user'] = session['user'] || h['source'].gsub(/[^a-zA-Z0-9]/, '')
142
+ h['running_drivers'] = qi['runningDrivers'] || 0
143
+ h['queued_drivers'] = qi['queuedDrivers'] || 0
144
+ h['completed_drivers'] = qi['completedDrivers'] || 0
145
+ h['total_drivers'] = qi['totalDrivers'] || 0
146
+ h['elapsed_time'] = qi['elapsedTime'] || '0.0m'
147
+ h['create_time'] = qi['createTime']
148
+ h['running_time'] = qi['endTime'] || Time.now.utc.iso8601(3)
149
+ #if(h['state'] == "FAILED")
150
+ # h['errorCode'] = find(h['query_id'])['errorCode'] || {}
151
+ #end
152
+ h
153
+ }
154
+ end
159
155
 
160
156
  def find_tasks(sub_stages)
161
157
  task_list = []
162
158
  return task_list unless sub_stages
163
- sub_stages.each{|ss|
159
+ sub_stages.each { |ss|
164
160
  tl = ss['tasks']
165
161
  task_list << tl if tl
166
162
  task_list << find_tasks(ss['subStages'])
@@ -1,5 +1,5 @@
1
1
  module Presto
2
2
  module Metrics
3
- VERSION = '0.3.9'
3
+ VERSION = '0.3.10'
4
4
  end
5
5
  end
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.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taro L. Saito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-12 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler