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

Add Splunk MultiMetric support #6640

Merged
merged 2 commits into from
Nov 18, 2019

Conversation

ronnocol
Copy link
Contributor

@ronnocol ronnocol commented Nov 8, 2019

Required for all PRs:

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

Adds support for Splunk 8.0's multi metric format.

}

func NewSerializer(splunkmetric_hec_routing bool) (*serializer, error) {
// NewSerializer Setup our new serializer
func NewSerializer(splunkmetric_hec_routing bool, splunkmetric_multimetric bool) (*serializer, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably switch to passing in enum types, similar to what was done in the influx serializer with UintSupport. This is just much more readable at the call point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what your ask here is. Happy to make changes with a little more direction.

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't super important, so we can do it later. What I've found is that having multiple boolean parameters to a function is somewhat hard to read. Compare these calls of the functions:

splunkmetric.NewSerializer(true, false)
splunkmetric.NewSerializer(HecRouting, NoMultiMetric)

Another advantage of this is that it is harder to mix up the argument order without getting a compile error.

Here is an example of defining a boolean type in the influx serializer:

type FieldSortOrder int
const (
NoSortFields FieldSortOrder = iota
SortFields
)

Again though, this isn't urgent, we can add it in a future change.

metricJson, err = json.Marshal(dataGroup.Fields)
}

metricGroup = append(metricGroup, metricJson...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the error before appending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
}
commonTags.Time = float64(metric.Time().UnixNano()) / float64(1000000000)
switch s.SplunkmetricMultiMetric {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest having two functions, one for multi metric and one for single. The idea being to keep these tasks as separate as possible and reduce the function length so that it can be more easily understood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Nov 13, 2019
@danielnelson danielnelson added this to the 1.13.0 milestone Nov 13, 2019
@danielnelson danielnelson merged commit bc8769b into influxdata:master Nov 18, 2019
@ronnocol ronnocol deleted the splunkmetric-multimetric branch November 20, 2019 18:57
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
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.

2 participants