Skip to content

Commit

Permalink
Default stack trace size to 50 and make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
danhermann committed May 21, 2019
1 parent 15ac5db commit 7cd6bb8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/static/monitoring-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ The parameters allowed are:

[horizontal]
`threads`:: The number of hot threads to return. The default is 10.
`stacktrace_size`:: The depth of the stack trace to report for each thread. The default is 50.
`human`:: If true, returns plain text instead of JSON format. The default is false.
`ignore_idle_threads`:: If true, does not return idle threads. The default is true.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

class HotThreadsReport
STRING_SEPARATOR_LENGTH = 80.freeze
HOT_THREADS_STACK_TRACES_SIZE_DEFAULT = 10.freeze
HOT_THREADS_STACK_TRACES_SIZE_DEFAULT = 50.freeze

def initialize(cmd, options)
@cmd = cmd
filter = { :stacktrace_size => options.fetch(:stacktrace_size, HOT_THREADS_STACK_TRACES_SIZE_DEFAULT) }
filter = { 'stacktrace_size' => "#{options.fetch(:stacktrace_size, HOT_THREADS_STACK_TRACES_SIZE_DEFAULT)}" }
@thread_dump = ::LogStash::Util::ThreadDump.new(options.merge(:dump => ThreadsReport.generate(filter)))
end

Expand Down
3 changes: 2 additions & 1 deletion logstash-core/lib/logstash/api/modules/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ def node
get "/hot_threads" do
begin
ignore_idle_threads = params["ignore_idle_threads"] || true

options = {:ignore_idle_threads => as_boolean(ignore_idle_threads)}
options[:threads] = params["threads"].to_i if params.has_key?("threads")
options[:ordered_by] = params["ordered_by"] if params.has_key?("ordered_by")
options[:stacktrace_size] = params["stacktrace_size"] if params.has_key?("stacktrace_size")

as = human? ? :string : :json
respond_with(node.hot_threads(options), {:as => as})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static List<ThreadReport> detect(Map<String, String> options) {
throw new IllegalArgumentException("Invalid sort order");
}

Integer threadInfoMaxDepth = 3;
Integer threadInfoMaxDepth = 50;
if (options.containsKey(STACKTRACE_SIZE)) {
threadInfoMaxDepth = Integer.valueOf(options.get(STACKTRACE_SIZE));
}
Expand Down

0 comments on commit 7cd6bb8

Please sign in to comment.