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

BufferCapacity - Doesnt take the 'last' n entries #6

Open
deepikakct opened this issue Dec 28, 2022 · 0 comments
Open

BufferCapacity - Doesnt take the 'last' n entries #6

deepikakct opened this issue Dec 28, 2022 · 0 comments

Comments

@deepikakct
Copy link

deepikakct commented Dec 28, 2022

Thanks for creating this sink! It is a very useful addition.

Came across this issue :
To create a new bag with half the items , following code is used in LogBuffer.cs
Bag = new ConcurrentBag<LogEvent>(logEvents.Take(Math.Max(1, config.BufferCapacity / 2)));

This uses "Take" which retrieves first 'n' elements (based on buffer capacity).

Consider the scenario:

  • BufferCapacity to 15
  • buffer all Debug messages (Say message 1 to message 19)
  • an error event happens after all the above debug messages

Issue: While Creating / PruningLogEntries : Instead of fetching last "n" entries from buffer , first "n" entries are fetched , which makes the log messages not sequential

Log message looks like:
2022-12-28 04:05:44.599|[ERR]|This is a trigger|
2022-12-28 04:05:44.596|[DBG]||Message Line number 0
2022-12-28 04:05:44.596|[DBG]|Message Line number 1
2022-12-28 04:05:44.596|[DBG]|Message Line number 2
2022-12-28 04:05:44.596|[DBG]|Message Line number 3
2022-12-28 04:05:44.596|[DBG]|Message Line number 4
2022-12-28 04:05:44.596|[DBG]|Message Line number 5
2022-12-28 04:05:44.599|[DBG]|Message Line number 15
2022-12-28 04:05:44.599|[DBG]|Message Line number 16
2022-12-28 04:05:44.599|[DBG]|Message Line number 17
2022-12-28 04:05:44.599|[DBG]|Message Line number 18
2022-12-28 04:05:44.599|[DBG]|Message Line number 19

Solution : use "TakeLast " to retrieve last "n" messages

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

No branches or pull requests

1 participant