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

Multiplot/fetch_multi changes #460

Merged
merged 10 commits into from
May 19, 2015
Merged

Multiplot/fetch_multi changes #460

merged 10 commits into from
May 19, 2015

Conversation

GeorgeJahad
Copy link
Contributor

Made a number of fixes/enhancements to the finder:

  1. Graphite requires the datapoints returned by the finder to be
    equidistant in time, (interleaved with Null datapoints if necessary.)
    We weren't doing this so the timescale was off on graphs with sparse data.
  2. Improved performance significantly by switching to fetch_multi/multiplot.
    (Note this required updating the graphite-api code from version 1.0.1 to
    Head of master. Since we also had to patch that code I created a new repo
    for it here: https://github.com/rackerlabs/graphite-api/tree/george/fetch_multi_with_patches
  3. One other detail about fetch_multi is that it has to take the multiplot limits into
    account. Multplot allows only 100 metrics per call, and has implicit limit of around
    7000 json characters. So my changes batch up each of graphite-apis fetch_multi() calls
    into to the minimum number of multiplot calls that still abide by those limits.
  4. Now supports specificy specific submetric names in the config file, (rather
    than just assuming "average", "num_points" or "latest" as we were before.
    This required changes on both the search side, and the fetch_multi side.
    This work was based on the changes suggested and created by Alex Weeks:
    https://github.com/aweeks
  5. Finally added a bunch of tests to get coverage of this file up to 93%:
    https://23282e1499f9e238db58e26751fc6d96be63cc17-www.googledrive.com/host/0B28IWTWKORCkfnlLYmljbW1NQ295NWhWbmtfbDJ1UXYwQm9xdlVuMjN0NFV1QTNmcDltY2M/x/blueflood.html

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 51.34% when pulling a0d8e81 on george/add_fetch_multi2 into 7072b54 on master.


if r.status_code == 200:
return [m['metric'] for m in r.json()]
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding retries over here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

People have been using it without a problem I think, and I've had to work on so many other issues that I'm not going to do this one yet.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 51.47% when pulling c21dd40 on george/add_fetch_multi2 into acc39a6 on master.


def complete(self, metric, query_depth):
metric_parts = metric.split('.')
if query_depth < len(metric_parts):
Copy link
Contributor

Choose a reason for hiding this comment

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

Totally up to you, but what do you think about consolidating these if statements into just one block like, if (query_depth < len(metric_parts)) or (self.enable_submetrics and (query_depth == len(metric_parts)))

@GeorgeJahad
Copy link
Contributor Author

These files have been updated per the review from chinmay-gupte.
The changes are as follows:

  1. Tried to simplify the find_nodes() method a bit by splitting
    it out into 2 separate methods depending on whether submetrics are
    used or not.
  2. Changed the term "cache" to "dictionary"
  3. No longer sorts timestamps, because they are sorted from BF.
  4. Chinmay suggested that we rollup metrics that coexist in the same
    "step", (instead of dropping all but the first.) However, this
    problem only occurs when full res metrics have sub-second frequencies.
    Since that seems to be a rare case, I've just documented the problem
    for now, and will fix it when it actually becomes a problem

Note that if you only want to see the diffs since the initial
version of this PR, you can see them like so:
git diff 6e7e811 c21dd40
or
6e7e811...c21dd40

# names, so return leaf nodes for each submetric alias that is
# enabled
if query_parts[-1] == '*':
for metric in self.find_metrics('.'.join(query_parts[0:-1])):
Copy link
Contributor

Choose a reason for hiding this comment

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

If the query ends with a * but its not for a leaf node, it will make a call to find_metrics here and because its not complete, it will make a call again to find_metrics to return a branch node. Are these actual API calls or the data returned is cached?

Copy link
Contributor

Choose a reason for hiding this comment

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

If its doing the former, can we make just one API call in this function to find_metrics and cache the data in a local variable?

@GeorgeJahad
Copy link
Contributor Author

The lastest diffs:
c21dd40...george/add_fetch_multi2

@coveralls
Copy link

Coverage Status

Coverage remained the same at 51.44% when pulling 22d4dd7 on george/add_fetch_multi2 into acc39a6 on master.

yield BranchNode('.'.join(parts[:query_depth]))
# First modify the pattern to get a superset that includes already complete
# submetrics
new_pattern = complete_pattern + '*'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the variable new_pattern same as original query.pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no it isn't. It is a superset which is what I was trying to explain in the comment. For example, if query.pattern is "a.b.", it won't return "a.b", so new_pattern is "a.b", with no second ".". Does that make sense? I'm trying to eliminate the second api call by combining the two.

@chinmay-gupte
Copy link
Contributor

+1 after my last comment has been addressed.

GeorgeJahad added a commit that referenced this pull request May 19, 2015
@GeorgeJahad GeorgeJahad merged commit c1cd5fb into master May 19, 2015
@GeorgeJahad GeorgeJahad deleted the george/add_fetch_multi2 branch May 19, 2015 22:45
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.

None yet

3 participants