-
Notifications
You must be signed in to change notification settings - Fork 264
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
add key value http logger #358
add key value http logger #358
Conversation
|
||
import static org.apiguardian.api.API.Status.EXPERIMENTAL; | ||
|
||
public abstract class AbstractPreparedHttpLogFormatter implements HttpLogFormatter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be an interface with default methods, couldn't it?
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class KeyValueHttpLogFormatter extends AbstractPreparedHttpLogFormatter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format is rather specific to splunk, why not call it SplunkHttpLogFormatter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, splunk just uses key-value pairs, but it does not mean that every key-value format consumer is splunk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but until someone comes along who needs something similar outside of splunk I'd prefer to be specific. That gives us a bit more freedom in evolving this along with splunk, if needed.
@Override | ||
public String format(final Map<String, Object> content) { | ||
return content.entrySet().stream() | ||
.map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any escaping that needs to be done for values that contain a =
e.g. the URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that is a idiomatic question.
Splunk for example is eating such format like uri=http://host?k=v
and allows you to search it. But also during the syntax highlighting, it suggest two pairs uri=http://host
and k=v
, which allow you to search those parameters bound to each other (full search) or independently (partial search). It is quite useful, when you have many parameters in uri, but you is interested in only some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to rename kv
to splunk
and the KeyValueHttpLogFormatter
to SplunkHttpLogFormatter
.
Can you resolve the conflict? |
Nevermind. I just saw that Github has a web editor for this now. Let's see whether it worked. |
Not really. Looks like the whole README is now somehow modified. |
ef88432
to
ad6a3c0
Compare
Yeah 😞. I had rebase my branch against master - looks better now. |
Thanks a lot for the contribution! 🎉 I'll prepare a new release as soon as I get to the office. |
Description
Add support key value http formatters
Motivation and Context
Some log collecting software (like Splunk), use key value logging formats by default.
Types of changes
Checklist: