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

Question about code #7

Open
jblaine opened this issue Aug 27, 2012 · 2 comments
Open

Question about code #7

jblaine opened this issue Aug 27, 2012 · 2 comments

Comments

@jblaine
Copy link
Contributor

jblaine commented Aug 27, 2012

What is this intending to do?

values = pieces[1].split(",")[:-1]

It strips the last data value returned from Graphite. I don't think that's what you wanted to do.

>>> myvalues = [8,9,10]
>>> myvalues[:-1]
[8, 9]
>>>

I think you were intending to strip the newline character from the graphite data line??

@jblaine
Copy link
Contributor Author

jblaine commented Aug 27, 2012

[ Thanks for making this and OSSing it. ]

Unless there's something going on in answer to the above question, I think you want the following.

try:
  (metadata, csv_values) = data.strip().split("|")
  counter = metadata.split(",")[0]
  values = csv_values.split(",")
except:
  graphite.unknown_error("Graphite returned bad data")

Note

  1. strip() to remove the newline before the split
  2. The try/except block to catch bad data
  3. The removal of the [:-1] as I can see no point for it

@nicolaskruchten
Copy link
Contributor

Your suggestion seems reasonable enough, although I can't remember why we did this in the first place. I think that maybe there was some issue whereby the last value was wrong or averaged weirdly or out of synch or something and since we were logging at 10-second granularity and alarming on a 1 or 5-minute basis, it didn't bother us too much to just throw away the last value.

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

No branches or pull requests

2 participants