Skip to content

Add time.now() starlark processor example test#9133

Merged
ivorybilled merged 1 commit intomasterfrom
addTimeNowStarlarkExample
Apr 19, 2021
Merged

Add time.now() starlark processor example test#9133
ivorybilled merged 1 commit intomasterfrom
addTimeNowStarlarkExample

Conversation

@ivorybilled
Copy link
Copy Markdown
Contributor

This adds the ability to mock the time.now() function in starlark and thus be able to create an example in which time.now() is used to set on metrics.

Copy link
Copy Markdown
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

🤝 ✅ CLA has been signed. Thank you!

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Apr 14, 2021
Copy link
Copy Markdown
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

Comment on lines -66 to +67
return loadFunc(module, s.Log)
return s.starlarkLoadFunc(module, s.Log)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the reason behind this?

Copy link
Copy Markdown
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.

The code looks good, but I'd like to prevent messing with the load function if possible. Can you please check if you can set times NowFunc` in the tests instead of overriding the load!?

@srebhan srebhan self-assigned this Apr 19, 2021
Copy link
Copy Markdown
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.

looks good. I think there's issues with replacing the load function because the module is loaded at runtime. Looks fine the way it is.

@ivorybilled ivorybilled merged commit da5991d into master Apr 19, 2021
@ivorybilled ivorybilled deleted the addTimeNowStarlarkExample branch April 19, 2021 15:14
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Aug 28, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants