Skip to content

Clarify threadNameFormat (and possibly add some words about it in the documentation) #578

Open
@brenuart

Description

@brenuart

Both the AsyncDisruptorAppender and LogstashTcpSocketAppender appenders allow for the customisation of the name of their processing threads. This customisation is done via a standard Java format pattern set via the threadNamePattern configuration parameter.

Although very handy, this feature does not seem to be documented in the project README. The javadoc however indicates that the following placeholders/arguments are supported:

  • %1: the appender name
  • %2: the numerical thread index
  • %3: the hostname of the connected destination
  • %4: the port of the connected destination

The actual meaning of the numerical thread index is not clear to me. At first it seems to be a unique number incremented every time a new thread is created. This index can be used to differentiate between threads if the remaining part of the name format is "fixed". For instance the pattern logstash-%2 will produce thread names like logstash-1, logstash-2 and so forth.
An appender like the TCP appender creates at most 4 threads depending on its configuration. With the previous pattern, threads will be named from logstash-1 to logstash-4. However, after a while, I found threads named with an index higher than 4 - like logstash-12. After some investigation it appears that the thread index is incremented every time a new thread name is computed and not when a thread is created. A new thread name is computed when the appender reconnects to another destination for instance...

Is it expected?

Also, the first thread index is 2 instead of 1 or 0. This is because the counter is initialised with 1 (see AsyncDisruptorAppender.java#L240) and incremented before it's value is used (see AsyncDisruptorAppender#L567).

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/questiona question (should be converted to discussion)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions