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

Change the Exec output to use BatchSerialize() #6446

Merged

Conversation

morfien101
Copy link
Contributor

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Solves #6445

When the exec output serialises the metrics it does it one by one and writes it to the buffer. Error checking is done on the serialising but not the writing into the buffer. So there is no reason to not use the batch serialiser.

When developing against the output exec I expected the output to follow the rules of the data format that I specified. For my use case I am using JSON and expected a list of metrics but was unfortunately greeted with a multiple lines of single metrics, making it extremely difficult to render the metrics again.

Sample of bad output:

{"fields":{"bytes_recv":0,"bytes_sent":0,"drop_in":0,"drop_out":0,"err_in":0,"err_out":0,"packets_recv":0,"packets_sent":0},"name":"net","tags":{"host":"pickle","interface":"br-0ac7079a5349"},"timestamp":1569418417000}
{"fields":{"bytes_recv":526400,"bytes_sent":1924156,"drop_in":0,"drop_out":0,"err_in":0,"err_out":0,"packets_recv":5289,"packets_sent":13564},"name":"net","tags":{"host":"pickle","interface":"docker0"},"timestamp":1569418417000}
{"fields":{"bytes_recv":0,"bytes_sent":0,"drop_in":0,"drop_out":0,"err_in":0,"err_out":0,"packets_recv":0,"packets_sent":0},"name":"net","tags":{"host":"pickle","interface":"br-349b964a2f38"},"timestamp":1569418417000}

This PR removes the looping over the metrics and rather just use the batch serialise function.

@danielnelson danielnelson added this to the 1.12.3 milestone Sep 26, 2019
@danielnelson danielnelson added the fix pr to fix corresponding bug label Sep 26, 2019
@danielnelson
Copy link
Contributor

This is a change of behavior of this newly introduced feature, but I think we are still within the grace period. We should try to always use SerializeBatch on any new code, and I'll add a comment officially deprecating the use of Serialize.

@danielnelson danielnelson merged commit 62c6e30 into influxdata:master Sep 26, 2019
danielnelson pushed a commit that referenced this pull request Sep 26, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants