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(inputs): Add option to choose the metric time source #15917

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LarsStegman
Copy link
Contributor

@LarsStegman LarsStegman commented Sep 20, 2024

Summary

Adds the option to set the timestamp to when gathering started/ended

Discussed in #15891

Checklist

  • No AI generated code was used in this PR

Related issues

@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 Sep 20, 2024
@srebhan
Copy link
Member

srebhan commented Oct 2, 2024

@LarsStegman there is no open issue for this I think...

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.

Code looks good except for using a new type. Simply go with the strings please!

@@ -1488,6 +1488,8 @@ func (c *Config) buildInput(name string, tbl *ast.Table) (*models.InputConfig, e
cp.CollectionJitter, _ = c.getFieldDuration(tbl, "collection_jitter")
cp.CollectionOffset, _ = c.getFieldDuration(tbl, "collection_offset")
cp.StartupErrorBehavior = c.getFieldString(tbl, "startup_error_behavior")
cp.TimeSource = models.TimeSourceType(c.getFieldString(tbl, "time_source"))
Copy link
Member

Choose a reason for hiding this comment

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

Please use a string here and do not introduce a new type.

Comment on lines +20 to +27
type TimeSourceType string

const (
TimeSourceMetric TimeSourceType = "metric"
TimeSourceCollectionStart TimeSourceType = "collection_start"
TimeSourceCollectionEnd TimeSourceType = "collection_end"
)

Copy link
Member

Choose a reason for hiding this comment

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

We don't need this, simply use the switch statement on strings.

@@ -87,6 +97,7 @@ type InputConfig struct {
CollectionJitter time.Duration
CollectionOffset time.Duration
Precision time.Duration
TimeSource TimeSourceType
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
TimeSource TimeSourceType
TimeSource string

@srebhan srebhan changed the title feat(inputs): time source feat(inputs): Add option to choose the metric time source Oct 2, 2024
@srebhan srebhan self-assigned this Oct 2, 2024
@srebhan srebhan added the plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins label Oct 2, 2024
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 plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants