Skip to content

Conversation

@ccui-wish
Copy link

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.ParentPath field always only has one element in its list. For instance, for a metric named serverStatus.metrics.aggStageCounters._addFields, its correct ParentPath should be ["serverStatus", "metrics", "aggStageCounters"]; however, when I printed out the actual ParentPath, it is ["serverStatus"].

I looked into the source code and found out that in the metricForType() function in the bson_metrics.go file, in the case where val is of type bsontype.EmbeddedDocument, the code loops through all its sub-documents and creates a new Metric struct for each of them. The problem there is that the ParentPath field 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' ParentPath become the parent path of their parent.

Hence, the solution is to define the ParentPath field 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant