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

perf: Async parsing #15884

Closed
LarsStegman opened this issue Sep 15, 2024 · 0 comments · Fixed by #15891
Closed

perf: Async parsing #15884

LarsStegman opened this issue Sep 15, 2024 · 0 comments · Fixed by #15891
Labels
bug unexpected problem or unintended behavior

Comments

@LarsStegman
Copy link
Contributor

LarsStegman commented Sep 15, 2024

Relevant telegraf.conf

Not relevant

Logs from Telegraf

Not relevant

System info

Telegraf 1.31.2, Ubuntu 24.02

Docker

No response

Steps to reproduce

  1. Receive UDP packets of 45KB at 50Hz
  2. Parse them using the binary parser
    ...

Expected behavior

Messages are timestamped properly and all received. The elapsed time between values is very erratic.

Actual behavior

Messages are sometimes timestamped late or missed

Additional info

After implementing #15883 in our custom build of Telegraf we still see that points are not being logged at a consistent 50Hz. Some points are late or are missed.

I experimented with calling the onData function in the inputs.socket_listener with go onData. This significantly improves the accuracy of the timestamping, because we no longer wait to read the buffer again while we are still parsing the previous message. I also had to add a feature that overrides the timestamp from the parser with the time recorded when the UDP packet is read from the buffer.

Elapsed time since last data point
image

Adding this greatly improves the accuracy and consistency of the timestamping. The way I implemented it is very hacky though and a better implementation is needed.

Possible solution

I would propose to add an interface ParserWithTimestamp or something like that. These kinds of parsers accept a timestamp from the input plugin they are used by and implement:

  • ParseWithTimestamp([]byte, time.Time) []telegraf.Metric
  • ParseLineWithTimestamp([]byte, time.Time) []telegraf.Metric

With this it is possible for parsers to give an option to the user to use the "input time" as the time source, or to use the other options the parser offers. My guess is that not many input plugins will actually use the "input time", except inputs.socket_listener.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant