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

Does it make sense to use high resolution timer for LogEvent? #893

Closed
harvinders opened this issue Nov 2, 2016 · 1 comment
Closed

Does it make sense to use high resolution timer for LogEvent? #893

harvinders opened this issue Nov 2, 2016 · 1 comment
Labels

Comments

@harvinders
Copy link

We are using serilog with Elasticsearch, and many times closely logged events in a single threaded application are coming off with the same timestamp. This causes confusion when another user tries to make sense of the chronology of events.

I looked at the code in Logger.cs and saw that it used DateTimeOffset.Now which according to MSDN Blog has the accuracy of 16ms. Would it not be a good idea to use Stopwatch instead?

Another option for us is to use enricher to add a timestamp property based on the Stopwatch, but then it will not play nicely with toolsets created on top of the Sinks (i.e kibana use the timestamp property generated by the ElasticSearch sink to order the display)

@nblumhardt
Copy link
Member

Thanks for the note. StopWatch has a cost, so I think we'd need to add support for some kind of "timestamp provider" - not sure how this would look, though, nor what kind of impact it might have on the API. Open to investigating further if there's no other option.

Even with very high precision/accuracy, there are always going to be events so close together their timestamps overlap. I'd be quite surprised to find that there's no way to maintain the ordering in ES. Perhaps raising a bug in https://serilog/serilog-sinks-elasticsearch would be a good starting point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants