Fix ParentPath missing label issue - #58
Open
ccui-wish wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I intended to use this ftdc package to pull out some useful metrics for MongoDB hosts. When I pulled out the list of metrics in each chunk, I found out that the name of the metrics is incomplete. More specifically, the
Metric.ParentPathfield always only has one element in its list. For instance, for a metric namedserverStatus.metrics.aggStageCounters._addFields, its correctParentPathshould be["serverStatus", "metrics", "aggStageCounters"]; however, when I printed out the actualParentPath, it is["serverStatus"].I looked into the source code and found out that in the
metricForType()function in thebson_metrics.gofile, in the case wherevalis of typebsontype.EmbeddedDocument, the code loops through all its sub-documents and creates a newMetricstruct for each of them. The problem there is that theParentPathfield of the new struct is defined to be the path of the current key instead of sub-keys, which would make all the sub-metrics'ParentPathbecome the parent path of their parent.Hence, the solution is to define the
ParentPathfield to be the actual parent path of that sub-document, which I have changed in this PR.To all maintainers of this repo: please review this PR and let me know if you have any questions/concerns!