Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

A metric can be changed from static to dynamic by setting Name parameter on NamespaceElement #937

Closed
geauxvirtual opened this issue May 19, 2016 · 1 comment

Comments

@geauxvirtual
Copy link
Contributor

Currently, the only determination if a metric namespace is dynamic or static is if Name is set on a NamespaceElement(s).

After creating a metric namespace via core.NewNamespace("intel", "mock", "foo"), there is nothing that prevents setting the Name field on the three NamespaceElements that make up this Namespace. Initially, IsDynamic() on this Namespace would return false. However, if a plugin were to go the extra step to set the Name field on each NamespaceElement, like so

ns[0].Name = "org"
ns[1].Name = "plugin"
ns[2].Name = "metric"

IsDynamic() will now return true on this metric namespace. Any tooling that would consume this information and display dynamic metrics different from static metrics would see an issue. As an example, this is what snapctl would display with the changes in PR #931

screen shot 2016-05-19 at 11 24 53 am

@jcooklin
Copy link
Collaborator

I feel that this issue should be addressed with documentation. Plugin writers should not set the name for a namespace field unless it's a dynamic.

The following exist to help plugin authors not have to deal with or think about the fields of NamespaceElement.

  • func NewNamespace(ns ...string) Namespace
  • func (n Namespace) AddDynamicElement(name, description string) Namespace
  • func (n Namespace) AddStaticElement(value string) Namespace
  • func (n Namespace) AddStaticElements(values ...string) Namespace

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants