-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
base: master
Are you sure you want to change the base?
Conversation
acd02e7
to
45a8c85
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
@LarsStegman there is no open issue for this I think... |
There was a problem hiding this 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")) |
There was a problem hiding this comment.
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.
type TimeSourceType string | ||
|
||
const ( | ||
TimeSourceMetric TimeSourceType = "metric" | ||
TimeSourceCollectionStart TimeSourceType = "collection_start" | ||
TimeSourceCollectionEnd TimeSourceType = "collection_end" | ||
) | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TimeSource TimeSourceType | |
TimeSource string |
Summary
Adds the option to set the timestamp to when gathering started/ended
Discussed in #15891
Checklist
Related issues