MCPcopy Create free account
hub / github.com/OpenTSDB/opentsdb / printThreadStats

Method printThreadStats

src/tsd/StatsRpc.java:184–205  ·  view source on GitHub ↗

Grabs a snapshot of all JVM thread states and formats it in a manner to be displayed via API. @param query The query to respond to

(final HttpQuery query)

Source from the content-addressed store, hash-verified

182 * @param query The query to respond to
183 */
184 private void printThreadStats(final HttpQuery query) {
185 final Set<Thread> threads = Thread.getAllStackTraces().keySet();
186 final List<Map<String, Object>> output =
187 new ArrayList<Map<String, Object>>(threads.size());
188 for (final Thread thread : threads) {
189 final Map<String, Object> status = new HashMap<String, Object>();
190 status.put("threadID", thread.getId());
191 status.put("name", thread.getName());
192 status.put("state", thread.getState().toString());
193 status.put("interrupted", thread.isInterrupted());
194 status.put("priority", thread.getPriority());
195
196 final List<String> stack =
197 new ArrayList<String>(thread.getStackTrace().length);
198 for (final StackTraceElement element: thread.getStackTrace()) {
199 stack.add(element.toString());
200 }
201 status.put("stack", stack);
202 output.add(status);
203 }
204 query.sendReply(query.serializer().formatThreadStatsV1(output));
205 }
206
207 /**
208 * Yield (chiefly memory-related) stats about this OpenTSDB instance's JVM.

Callers 1

executeMethod · 0.95

Calls 9

putMethod · 0.80
sendReplyMethod · 0.80
serializerMethod · 0.80
sizeMethod · 0.65
getIdMethod · 0.65
getNameMethod · 0.65
toStringMethod · 0.45
addMethod · 0.45
formatThreadStatsV1Method · 0.45

Tested by

no test coverage detected