Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some corrections and performance improvements in CorrelationIdFilter #183

Merged

Conversation

j-denner
Copy link
Contributor

@j-denner j-denner commented Jul 5, 2024

  • Directly extract correlation-id from traceparent without creating a string array and two not used substrings.
  • Remove not(<>) predicate since it leads (very likely) to allocation. By using ?: it could be formulated without negation.

…tring array and two not necessary substrings.

* Remove not(<>) predicate since it leads (very likely) to allocation. By using ?: it could be formulated without negation.
* traceparent parsing without String[] and not required substring creation.
* Fix debug log entry. Additional parameter was given but without corresponding format specifier.
Copy link
Contributor

@KarstenSchnitter KarstenSchnitter left a comment

Choose a reason for hiding this comment

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

Thanks, for providing this PR. I will run the jmh tests to see, what benefit this implementation brings. Please clarify the removal of the custom field in the log message.

Comment on lines 62 to 59
LOG.debug("Generated new correlation-id <{}>", correlationId, customField(correlationHeader.getField(),
correlationId));
LOG.debug("Generated new correlation-id <{}>", correlationId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you think, the custom field can go? By what mechanism will it be part of this log message?

Copy link
Contributor Author

@j-denner j-denner Jul 5, 2024

Choose a reason for hiding this comment

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

I removed it because, there is no corresponding {} to the field in the format string.
There are two solutions to this, either enhancing the format string and keep the field entry (I assume that's your intend) or as I did - remove the currently not used argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, this is a silent parameter. It is not rendered in the pattern but still picked-up by the JSONEncoder. This will render a custom field "correlation-id": "UUID" in the log message. It is the work-aroung in SLF4J 1.x, where there are no key-value-pairs available for this purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the explanation, I'll revert this part.

@KarstenSchnitter KarstenSchnitter merged commit 4a3518b into SAP:main Jul 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants