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

feat: Add support of aggregator as Starlark script #9419

Merged
merged 8 commits into from
Nov 18, 2021
Merged

feat: Add support of aggregator as Starlark script #9419

merged 8 commits into from
Nov 18, 2021

Conversation

essobedo
Copy link
Contributor

@essobedo essobedo commented Jun 23, 2021

Required for all PRs:

  • Updated associated README.md.
  • Wrote appropriate unit tests.

resolves #8869

@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin new plugin plugin/aggregator 1. Request for new aggregator plugins 2. Issues/PRs that are related to aggregator plugins labels Jun 23, 2021
@essobedo
Copy link
Contributor Author

@ssoroka It is not yet ready since the doc is missing but I would like to be sure that it is the right direction so could you please tell me WDYT of this PR?

Copy link
Contributor

@ssoroka ssoroka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking pretty good. left a few questions

plugins/aggregators/starlark/starlark.go Show resolved Hide resolved
plugins/aggregators/starlark/testdata/merge.star Outdated Show resolved Hide resolved
plugins/aggregators/starlark/testdata/merge.star Outdated Show resolved Hide resolved
plugins/aggregators/starlark/testdata/min_max.star Outdated Show resolved Hide resolved
plugins/processors/starlark/starlark.go Outdated Show resolved Hide resolved
@essobedo essobedo requested a review from ssoroka July 3, 2021 14:29
@sjwang90
Copy link
Contributor

@essobedo - would you like someone to continue reviewing this PR? If so, feel free to take it out of its draft state.

@essobedo essobedo marked this pull request as ready for review September 16, 2021 06:57
@essobedo essobedo changed the title Add support of aggregator as Starlark script feat: Add support of aggregator as Starlark script Sep 18, 2021
@essobedo
Copy link
Contributor Author

@essobedo - would you like someone to continue reviewing this PR? If so, feel free to take it out of its draft state.

@sjwang90 yes please 🙏

@reimda reimda removed the request for review from ssoroka September 24, 2021 20:29
plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/testdata/min_max.star Outdated Show resolved Hide resolved
@essobedo essobedo requested a review from reimda October 8, 2021 08:33
@essobedo
Copy link
Contributor Author

essobedo commented Oct 8, 2021

@reimda thank you for your review, I addressed your remarks so please check again

@essobedo
Copy link
Contributor Author

@reimda any other remarks about this PR?

@essobedo
Copy link
Contributor Author

essobedo commented Nov 4, 2021

@srebhan Hi, could you please tell me what you think of this PR?

@sjwang90
Copy link
Contributor

sjwang90 commented Nov 4, 2021

@essobedo If all the comments above are addressed can you make sure to mark them as resolved. We can then get someone to do another review on the PR.

@essobedo
Copy link
Contributor Author

essobedo commented Nov 4, 2021

@sjwang90 Yes it is what I did except for remarks for which I gave an answer, as I did not get any approval, I considered them as still open

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @essobedo for the cool PR. I think it makes sense to provide a scriptable aggregator. We need to work a bit on the structure though. I second the view of @reimda to use the state as a shared thing to persist values and I think there is nothing speaking against such an approach. Furthermore, we should follow the Aggregator interface also in starlark, i.e. having a add, push and reset function as people are used to those and there is documentation on what they are intended to do.

What do you think?

plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/aggregators/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/aggregators/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/aggregators/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/processors/starlark/starlark_test.go Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this Nov 5, 2021
@essobedo essobedo requested a review from srebhan November 8, 2021 10:52
@essobedo
Copy link
Contributor Author

essobedo commented Nov 8, 2021

@srebhan thank you for your feedbacks, I addressed your remarks, please check again

plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/aggregators/starlark/starlark.go Outdated Show resolved Hide resolved
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice update @essobedo! Some more ideas to move more code into common... :-)

@essobedo essobedo requested a review from srebhan November 8, 2021 14:56
@essobedo
Copy link
Contributor Author

essobedo commented Nov 8, 2021

@srebhan I improved the function InitFunction based on your remarks and used the same code to manage the resulting value of the Call functions.

@essobedo essobedo requested a review from srebhan November 9, 2021 11:04
@essobedo
Copy link
Contributor Author

essobedo commented Nov 9, 2021

@srebhan function AddResultingValue and related changes have been reverted. A map has been used as requested to store the functions and the arguments, please check again

@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Nov 9, 2021

🥳 This pull request decreases the Telegraf binary size by -0.05 % for linux amd64 (new size: 130.7 MB, nightly size 130.8 MB)

📦 Looks like new artifacts were built from this PR.

Expand this list to get them here! 🐯

Artifact URLs

DEB RPM TAR GZ ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm freebsd_amd64.tar.gz windows_i386.zip
armel.deb armv6hl.rpm freebsd_armv7.tar.gz
armhf.deb i386.rpm freebsd_i386.tar.gz
i386.deb ppc64le.rpm linux_amd64.tar.gz
mips.deb s390x.rpm linux_arm64.tar.gz
mipsel.deb x86_64.rpm linux_armel.tar.gz
ppc64el.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_s390x.tar.gz
static_linux_amd64.tar.gz

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. I still want to avoid the //nolint "magic" when calling Call and have a suggestion. Please let me know what you think.

plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
@essobedo
Copy link
Contributor Author

Almost there. I still want to avoid the //nolint "magic" when calling Call and have a suggestion. Please let me know what you think.

fixed, please check again

@telegraf-tiger
Copy link
Contributor

🥳 This pull request decreases the Telegraf binary size by -0.04 % for linux amd64 (new size: 130.7 MB, nightly size 130.8 MB)

📦 Looks like new artifacts were built from this PR.

Expand this list to get them **here**! 🐯

Artifact URLs

DEB RPM TAR GZ ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm freebsd_amd64.tar.gz windows_i386.zip
armel.deb armv6hl.rpm freebsd_armv7.tar.gz
armhf.deb i386.rpm freebsd_i386.tar.gz
i386.deb ppc64le.rpm linux_amd64.tar.gz
mips.deb s390x.rpm linux_arm64.tar.gz
mipsel.deb x86_64.rpm linux_armel.tar.gz
ppc64el.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_s390x.tar.gz
static_linux_amd64.tar.gz

@essobedo
Copy link
Contributor Author

Please note that the build failure is not related to this change

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beautiful @essobedo! Some more minor comments... :-/

plugins/aggregators/starlark/starlark.go Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/common/starlark/starlark.go Outdated Show resolved Hide resolved
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect @essobedo. Thank you very much for your work!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Nov 16, 2021
Copy link
Contributor

@reimda reimda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @essobedo! This PR is getting very close. Could you take a look at how metrics are hashed? If we can resolve that (and a typo I found), I think it's ready to merge.

plugins/aggregators/starlark/README.md Outdated Show resolved Hide resolved
plugins/aggregators/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/processors/starlark/starlark.go Outdated Show resolved Hide resolved
plugins/processors/starlark/starlark_test.go Outdated Show resolved Hide resolved
plugins/common/starlark/metric.go Outdated Show resolved Hide resolved
@essobedo essobedo requested a review from reimda November 17, 2021 08:41
@essobedo
Copy link
Contributor Author

essobedo commented Nov 17, 2021

@reimda Fixed, please check again

@telegraf-tiger
Copy link
Contributor

@reimda reimda merged commit 4f2ade5 into influxdata:master Nov 18, 2021
@reimda
Copy link
Contributor

reimda commented Nov 18, 2021

Thanks @essobedo for all your work on this!

@essobedo essobedo deleted the 8869/starlark-as-aggregator branch November 19, 2021 08:00
@MyaLongmire
Copy link
Contributor

@essobedo Thank you so much for this pr! There is a leftover //nolint comment that is keeping the file from being linted. I removed it in this pr but didn't touch anything else, just wanted to let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin new plugin plugin/aggregator 1. Request for new aggregator plugins 2. Issues/PRs that are related to aggregator plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Officially support aggregator Starlark scripts
6 participants