-
Notifications
You must be signed in to change notification settings - Fork 294
SDI-1394 a metric can be changed from static to dynamic by setting na… #977
Conversation
This is bad fix. Then this is used to strip such namespace element from metric name: |
@imroz, thanks for reviewing it. From my understanding, IsDynamic only applies to the metric types, not metric data themselves. I don't see two issues you linked. Thoughts? |
@candysmurf Dynamic metric as exposed by So example scenario is:
Now, publisher is going to put such rows in database:
It does this by inspecting namespace elements using But notice
|
@lmroz, thanks for your examples. However, I tried with Snap master where it does not have my change. It does not do what you expected. IMHO, in the publishers, we know if it's a dynamic or static metric and the position of wildcard "*" The wildcard may be in many places beyond your examples. We could have a scenario where stripping some of them and keeping a few of them. In another word, publishers should do diligent based on use cases. For example if you like to store "/org/power_consumption" instead of "/org/host1/power_consumption". In summary, IsDynamic should only check for metric types that defined in the task manifest. It has no other purpose. If it does, it's wrong itself. Please share your thoughts. |
@candysmurf Emily, Lukasz is right. This fix will break handling of dynamic metrics further in the pipeline. You can't leave "*" in dynamic metric after collection. You have to change the |
@marcin-krolik, @lmroz: I cannot agree that the IsDynamic function is useful in collectors. For a publisher plugin, if we have to depend on IsDynamic to decide what to do for the incoming metric data, does it mean that we'll need to populate the name for each dynamic element when we're collecting the data? Is there any better and scalable way to achieve this when we're trying to address this bug. Share your thoughts. |
@lmroz , @marcin-krolik, @jcooklin, @geauxvirtual , @intelsdi-x/plugin-maintainers: I propose to remove IsDynamic function entirely. It's flawed. To use your example, when we create a namespace, it should be in the following format: /org/host/host1/power_consumption A publisher can strip off both "/host/host1" and "/host/host2" to create tags. Another even more obvious approach could be /org/host=host1/power_consumption or /org/ So that you definitely know which one to remove and create tags. |
I am failing to understand what issue this PR is attempting to fix. I did read #937, but I don't understand why a plugin would want to give names to namespace elements (e.g. |
@candysmurf Problem with your PR is that it tries to address reported bug incorrectly. I had the same confusion when I reported #949 .
In short, you were asked to collect such metric This metric was created with namespace as metric.Namepace_ = core.NewNamespace("intel").AddDynamicElement("host_ip", "IP address of the host").AddStaticElement("foo") In
If you will choose 1 like: metric.Namespace_: core.NewNamespace("intel", "10.1.1.2", "foo"). then you will loose information of dynamic origin of the metric. Publisher will have no way to get rid of unwanted namespace element which is "10.1.1.2" If you go with 2, follow the example from mock collector then you don not loose dynamic origin of the metric, because second Hope it helps. |
@elemoine, @marcin-krolik : Thanks for your reply. I understood that my PR will not work for some of publishers and processors as there are dependencies on "IsDynamic" checking and can only check for the name field of the struct. Please read issue #937, users can set the "name" for static elements. Purely checking if the name is not empty to assume that the element is dynamic itself is flawed. Note that if collectors didn't set the name during the data collection, even we keep the current IsDynamic checking for publishers or processors, it'll not achieve the result you expected. I have my proposal in above comment to decouple the dependency on "IsDynamic" Please share your thoughts and if you still like to keep the coupling between Snap, Collectors, Processors, Publishers through "IsDynamic". |
@candysmurf I'm aware of #937. At the same time I don't think either removal of First solution which comes to my mind could based on introduction of interface instead of |
@marcin-krolik. It's a good suggestion to use interface. Let's think along this line. I'm afraid that many plugins will still need to be changed as any dynamic element will need to provide the name field in order for IsDynamic to work appropriately. The amount of refactoring may be not any less. Anyway, thanks for your suggestion, I like it! |
An interface cannot be decoded which will cause some headaches I would consider addressing this issue with plugin authoring documentation. I added a comment to #937 suggesting the same. |
I see two options here:
|
@marcin-krolik, interface idea is brilliant and idiomatic to me. I was able to use custom marshal and unmarshal to address the polymorphic element slice. Unfortunately, GOB was not happy with the following error. e.g.
I tried to stick to the original variable and method names as much as possible. I'm not sure if Joel meant the same thing. @imroz, I didn't get what you suggest. Please elaborate. thanks. |
7754a41
to
899a42f
Compare
|
||
func init() { | ||
gob.Register(&StaticElement{}) | ||
gob.Register(&DynamicElement{}) |
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.
I don't know if we want to have register going on in multiple places.
We also need to use gob.RegisterName() to avoid import path issues in the future.
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.
Agreed, where do you suggest to put them?
First solution I proposed is simply adding piece of code like this:
in these places: Second one is IMO better. We would have 3 types of
Anyway, validation like in first solution has to be added to disallow unwanted combination of empty |
@lmroz, thanks for the details. The first option will not require a lot of changes if only two places that we need to patch. Please confirm this. Agreed, the second one is better and I believe it's doable technically. It requires a lot of changes inside Snap. I already spent some effort similar to the second approach. I still need to tackle GRPC part and change a lots "[]core.Namespace" to []core.NamespaceElement" and test. Changes will be extensive. Before I put all my effort into it, I would like to get your inputs. Basically, we have following suggestions:
|
99.9% sure it's only these 2 places (AFAIK we don't touch binary data that goes out of processor), but remember that in CollectMetrics you have to check in metric catalog if namespace element was static and then collector assigned a |
@lmroz, thanks for the confirmation and two links. Basically, two scenarios we'll throw an error.
These two checks will be done for every metric collected. Do you have any concern regarding
If not, this probably is the simplest fixable solution although it's not ideal. Please share your thoughts. |
20a31c0
to
149833e
Compare
@lmroz, @marcin-krolik: Luaksz's proposal #1 is implemented. Please review and share your thought if Snap really wants to enforce the validation in control.go. I didn't throw errors instead logged them. |
/intel/cassandra/node/zeus/type/Cache/scope/KeyCache/name/Requests/OneMinuteRate | ||
/intel/cassandra/node/zeus/type/ClientRequest/scope/CASRead/name/Unavailables/FiveMinuteRate | ||
/intel/cassandra/node/apollo/type/Cache/scope/RowCache/name/Hits/OneMinuteRate | ||
/intel/cassandra/node/apollo/type/ClientRequest/scope/RangeSlice/name/Latency/OneMinuteRate |
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.
Very minor but isn't the convention to use the snake notation in metric namespaces?
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.
@elemoine, what's the snake notation? is it [1][2][3][4]?
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.
sorry_for_not_being_more_explicit :)
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.
@elemoine: thanks for the clarification! Agreed that snake_case could be easier to read comparing to CamelCase. In my example, I copied them from the Cassandra collector. Those camel cases were from MX4J APIs.
Are you suggesting that Snap should standardize cases in namespaces to Snake Case?
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 do not have a standardization on this for namespaces. I prefer whatever is closest to the resources. In this case @candysmurf has then coupled well with the Cass collector which is good.
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.
I think it should hopefully be consistent inside a plugin. But it is not something we can control.
@candysmurf I've added a number of comments in the code. Feel free to ignore me if my comments are not valid/relevant :) |
b5e2009
to
4cdb353
Compare
@elemoine, thanks for your feedback! Please take another look and let me know if any other suggestions. thank you. |
I got an idea to enhance collectors so that they're TimeDB friendly. The good thing is that it'll not have a dependency on "IsDynamic()". There will be no modification to publishers and minimum changes to collectors. I'm implemented it in both Cassandra and Redfish collectors. They'll be ready for review soon. With that said, setting the name for a dynamic or static element is irrelevant. Developers can have the freedom to use the |
@jcooklin, Updated the doc. Please review this PR and let me know if anything you like me to change. thank you. |
3b23bcc
to
fd9468a
Compare
@jcooklin , Well done! Thanks for the collaboration! |
return fmt.Errorf("A static element %s should not define name %s for namespace %s.", value, name, ns) | ||
} | ||
|
||
func errorMetricDynamicElemnetHasNoName(value, ns string) error { |
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.
There's a typo here. should be:
func errorMetricDynamicElementHasNoName(value, ns string) error
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.
corrected. Thanks!
👍 |
Fixes #937
Summary of changes:
Testing done:
@intelsdi-x/snap-maintainers