feat(inputs.vsphere): Allow adding custom properties as fields#19161
feat(inputs.vsphere): Allow adding custom properties as fields#19161tguenneguez wants to merge 31 commits into
Conversation
|
Thanks for your contribution @tguenneguez! Can you please check and fix the linter issues!? Furthermore, you can't check "I've used no AI" and "I've used AI" at the same time. :-) Please fix the checkboxes in the PR description. :-) |
|
Yes, I have seen it, but I do lot off think in the same time so, i change when I have time. |
srebhan
left a comment
There was a problem hiding this comment.
Thanks for your contribution @tguenneguez! I do have some comments in the code. IMO, the most important issues are
- You are changing unrelated parts of the code resulting in a larger diff than necessary. Please avoid changing code you don't need to touch in this PR. If you want it changed, do it in a separate PR!
- Spelling and comments are French AFAICS. Please check spelling and convert everything to English please!
Looking forward to your update of the PR!
| // resourceInfo is a utility class grouping a type and relevant parameters. | ||
| type resourceInfo struct { | ||
| resType string | ||
| custoFields []string |
There was a problem hiding this comment.
This abbreviation saves one character while humpering readability a lot. Please be generous and add the m here. :-)
There was a problem hiding this comment.
It's because of resourceFilter containe a resType
There was a problem hiding this comment.
Sorry but custo is not a word! Use customFields please. I don't see how this is related to resType or resourceFilter at all.
| fields = append(fields, af...) | ||
| } | ||
| fields = append(fields, resourceInfo.custoFields...) | ||
| uniqueFields := removeDuplicates(fields) |
There was a problem hiding this comment.
fields are defined by resourceInfo.custoFields which in turn stem from user-settings, don't they? If so, wouldn't it be better to deduplicate those user-settings in Init instead of doing it in every gather cycle?
There was a problem hiding this comment.
It will be, but they are agregate to addFields[resourceInfo.resType].
To be able to do this, it will be necessaire to agregate this info only one time...
There was a problem hiding this comment.
I'm talking about removeDuplicates here. You are removing duplicates from something that is user-set and does not change over the lifetime of the plugin (that's at least my understanding). Instead of doing this every time you collect data you could remove the duplicates once in the plugin's Init function and save processing time by removing the function call here.
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
…uenneguez/telegraf into add-custom-properties-vsphere
srebhan
left a comment
There was a problem hiding this comment.
Thanks @tguenneguez for your update. I have some more comments. Please check spelling of your variables as propertie is not an English word.
| include []string | ||
| simple bool | ||
| metrics performance.MetricList | ||
| parent string | ||
| latestSample time.Time | ||
| lastColl time.Time | ||
| propertieInclude []string |
There was a problem hiding this comment.
Spelling. How about
| propertieInclude []string | |
| propertiesInclude []string |
| // resourceInfo is a utility class grouping a type and relevant parameters. | ||
| type resourceInfo struct { | ||
| resType string | ||
| custoFields []string |
There was a problem hiding this comment.
Sorry but custo is not a word! Use customFields please. I don't see how this is related to resType or resourceFilter at all.
| } | ||
|
|
||
| // findAll returns the union of resources found given the supplied resource type and paths. | ||
| func (f *finder) findAll(ctx context.Context, resType string, paths, excludePaths []string, dst interface{}) error { | ||
| func (f *finder) findAll(ctx context.Context, resourceInfo resourceInfo, paths, excludePaths []string, dst interface{}) error { |
There was a problem hiding this comment.
Having variables named the same as types is usually confusing, how about
| func (f *finder) findAll(ctx context.Context, resourceInfo resourceInfo, paths, excludePaths []string, dst interface{}) error { | |
| func (f *finder) findAll(ctx context.Context, resource resourceInfo, paths, excludePaths []string, dst interface{}) error { |
| fields = append(fields, af...) | ||
| } | ||
| fields = append(fields, resourceInfo.custoFields...) | ||
| uniqueFields := removeDuplicates(fields) |
There was a problem hiding this comment.
I'm talking about removeDuplicates here. You are removing duplicates from something that is user-set and does not change over the lifetime of the plugin (that's at least my understanding). Instead of doing this every time you collect data you could remove the duplicates once in the plugin's Init function and save processing time by removing the function call here.
| func capitalizeAfterDot(input string) string { | ||
| var result []rune | ||
| for i, r := range input { | ||
| if i == 0 || input[i-1] == '.' { | ||
| result = append(result, unicode.ToUpper(r)) | ||
| } else { | ||
| result = append(result, r) | ||
| } | ||
| } | ||
| return string(result) | ||
| } |
There was a problem hiding this comment.
Please do the capitilization in getExtraData or do it in Init if the input is based on user settings.
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
Summary
Add the capabilitie to collecte properties of elements.
For sample :
This change collect data for VM Power Off. There was no information about this subtility.
Checklist
Related issues
resolves #18858