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

generated log time skew #55

Open
jsermer opened this issue Apr 21, 2022 · 0 comments
Open

generated log time skew #55

jsermer opened this issue Apr 21, 2022 · 0 comments

Comments

@jsermer
Copy link

jsermer commented Apr 21, 2022

NOTE: I'm not a 'go' programmer by trade and I love the diagrams python module you created...thanks for your contributions!

While using your tool to generate some logs while performance testing a log shipper setup, I noticed the timestamp in the emitted logs (while using the -l forever option), slowly became further and further behind the current time. This made it appear that the log shipper was lagging behind.

A basic test I performed was as follows:

Run the flog generator

./flog -f json -o /tmp/json.log -t log -d 1ms -l

In another terminal, every few seconds compare the last log line with the current date:

tail -1 /tmp/json.log && date

What you'll notice is the timestamp in the last log line slowly gets behind from the current time.

I was able to make a minor modification to flog.go which corrected the problem:

diff --git a/flog.go b/flog.go
index 896026b..728a1dc 100644
--- a/flog.go
+++ b/flog.go
@@ -38,7 +38,7 @@ func Generate(option *Option) error {
        if option.Forever {
                for {
                        time.Sleep(delay)
-                       log := NewLog(option.Format, created)
+                       log := NewLog(option.Format, time.Now())
                        _, _ = writer.Write([]byte(log + "\n"))
                        created = created.Add(interval)
                }

EDIT: Your implementation allows for better precision (using delays less than 1ms), it's just the slow skew that I'm not sure can be completely accounted for since the load generator requires some wall time to execute as well.

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