Add Peek() method to ThreadContextStack and LogicalThreadContextStack.#101
Add Peek() method to ThreadContextStack and LogicalThreadContextStack.#101fluffynuts merged 3 commits intoapache:masterfrom andreycha:feat/support-peek-in-stacks
Conversation
|
Hi @fluffynuts , could you please check this PR? Thanks! |
fluffynuts
left a comment
There was a problem hiding this comment.
LGTM
I can't make any promises about when this gets out live - I haven't had a lot of time to put into this in a while ): I'm currently formulating a plan to do beta / prerelease packages with less release friction so that perhaps at least things can get out quicker, but I have to speak with more venerable Apache people on what's process would be acceptable.
|
Thanks! Is there a way to somehow get notified when a new release comes out? |
|
@andreycha I guess you could sub to apache logging email lists; but I really want to figure out a way to do beta releases, and I doubt they'd go through that, so 🤷 I haven't figured this out yet ): I have this tension between "actual releases are a major mission with a lot of dead time whilst I wait for a bunch of Java people to vote on a dotnet thing that they have no context about" and "I just want to release fixes" )': |
|
Yeah, I can relate. Anyway, looking forward to the new release! |
Change
Add
Peek()method toThreadContextStackandLogicalThreadContextStackto be able to get the most recent value from the context without removing it.Motivation
In the scope of ElasticCommonSchema .NET integration for log4net log entry properties are being read and written to ECS format. In case of context stacks current implementation takes string representation of the stack. It works fine when stack (i.e., property) has a single value, but there are also cases when stack contains multiple values (same or different ones). With the proposed changes it will be able to take the most recent value, in the context of which the current log entry is being written.
Consider following scenario:
Alternative solutions considered
An alternative approach might be to just pop the most recent value and then push it again onto the stack. Problem here is that it creates a new scope which will not be closed as no one will call
Dispose()on the returned result fromPush().