elastic / logstash

Logstash - transport and process your logs, events, or other data
https://www.elastic.co/products/logstash
Other
75 stars 3.5k forks source link

Add plugin id to input worker thread name. #9647

Open guyboertje opened 6 years ago

guyboertje commented 6 years ago

When using multiple inputs of the same type it will be easier to identify the input thread in a hot threads or JVM thread dump if we can put an id in the thread name.

  def inputworker(plugin)
    Util::set_thread_name("[#{pipeline_id}]<#{plugin.class.config_name}")

This also might enable some interesting UI info from monitoring.

andrewvc commented 6 years ago

This is a great idea from a UX perspective.

Fun fact for anyone (attempting) to implement this, changing a thread name in java is not threadsafe! There's a long exchange on the concurrency interest mailing list about this.

IIRC, the general recommendation is to set the thread name once, not frequently.

Maybe there's some other way to get the same sort of introspection via the HTTP UI with our own datastructure? I suspect, unfortunately, that anything synchronized will bear a performance cost. However, a volatile String may not be so bad.

@original-brownbear what are your thoughts WRT perf impact here with the Java exec?

andrewvc commented 6 years ago

Oh, here's the link to the mailing list thread: http://cs.oswego.edu/pipermail/concurrency-interest/2013-March/010935.html

original-brownbear commented 6 years ago

@andrewvc I don't think changing the thread name will be a performance issue (you'd only synchronise in the setup phase of the pipeline anyways wouldn't you?). The input threads aren't logically related to the Java exec in any way though, so Java exec isn't what you should worry about here in the first place.