Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Collector structure #810

Merged
merged 1 commit into from
Jul 14, 2015
Merged

Conversation

anushree-n
Copy link
Contributor

@rjnagal , @vmarmol This is a rough draft of how we could change the Collector structure

The newly added fields 'minPollingFrequency' and 'regexps' in collectorInfo field in Collector structure are necessary for collection of metrics.
We can avoid calculation of these during actual metric collection to prevent repeated calculation during every metric calculation.

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@cadvisorJenkinsBot
Copy link
Collaborator

Can one of the admins verify this patch?

}

//regexprs[ind] is set to nil if metricConfig.Regex cannot be parsed
regexprs[ind], _ = regexp.Compile(metricConfig.Regex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not fail collector creation if regex can't be compiled?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to checking the error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to allow collection of other valid metrics by creating the constructor even if a few regexps errored. Can we can remove the entire metric whose regex is invalid and proceed with creation of a collector if there is atleast one valid metric?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is that if regex compile fails, then we should just error out and not create the collector. If we do partial collections, it might be hard for the user to notice that something was actually wrong with supplied regex. Failing to collect a metric is okay and we can continue processing, but invalid regex is probably something user should be reported back to user with a failure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought (and I think Rohit's too), is that here we're able to tell the user that their config is wrong and allow them to fix it.

You bring up a good point about trying to fail with reduced functionality (but in that case, we should at least return the error). Only concern is that if some metrics show up and some don't the user would think that something was broken in cAdvisor (or that the metric is empty), whereas a clear yes no to the metric would possibly make them think the config was wrong.

We can go either way :) but I think this makes it clear that we should be doing very good reporting of errors on metric collection so users know what's happening. We should export some stats and possibly a page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it looks like we were on the same page @rjnagal :) lol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the point It might be unclear to the user how only a few metrics have been collected. Thanks @rjnagal @vmarmol . Will fix it.

@rjnagal
Copy link
Contributor

rjnagal commented Jul 10, 2015

ok to test

@rjnagal
Copy link
Contributor

rjnagal commented Jul 10, 2015

small nit on not keeping errored collectors around. looks okay otherwise.

@@ -45,8 +57,20 @@ func NewCollector(collectorName string, configfile string) (*GenericCollector, e

//TODO : Add checks for validity of config file (eg : Accurate JSON fields)

minPollFrequency := configInJSON.MetricsConfig[0].PollingFrequency
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check that there is at least one (we have the TODO above, but we should at least check that so we don't crash)

@rjnagal
Copy link
Contributor

rjnagal commented Jul 14, 2015

LGTM

rjnagal added a commit that referenced this pull request Jul 14, 2015
@rjnagal rjnagal merged commit 9e1101f into google:master Jul 14, 2015
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.

5 participants