Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Resolve host name once per appender instead of once per log message #18

Merged
merged 4 commits into from Jul 6, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jun 25, 2018

This fixes a bug where the host name was resolved for each log message (if it was not set explicitly in the log config). For my benchmarks this increased throughput by ~15%.

I also made a couple more variables final.

@emil-genov
Copy link
Contributor

Nice one man. Good find. And improvement is nice

Copy link
Owner

@sandra-thieme sandra-thieme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @agrove-rms! Thanks for you pull request, you make a good point here. I like the overall changes but can you take a look at my comment regarding the additional fields?

for (Map.Entry<String, String> entry : event.getMDCPropertyMap().entrySet()) {
builder.additionalField(entry.getKey(), entry.getValue());
}
this.additionalFields.putAll(event.getMDCPropertyMap());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change introduces a bug. Previously the dynamic additional fields where only added to the builder, not to the appenders this.additionalFields (these are only the additional fields from the configuration file).

Say a log event comes with property foo included in the MDC, than this property is added to this.additionalFields and all those additional fields are included in the builder. That's fine so far. But when there's a second log event without the property foo, then this event's gelf message should not include foo (but it will with this change).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch. Working on fixing this now.

@ghost
Copy link
Author

ghost commented Jul 5, 2018

I reverted the change to additionalFields

@sandra-thieme sandra-thieme merged commit 8e574b0 into sandra-thieme:master Jul 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants