graphite-project / graphite-web

A highly scalable real-time graphing system
http://graphite.readthedocs.org/
Apache License 2.0
5.89k stars 1.26k forks source link

Errors with graphType=pie #1983

Closed cbowman0 closed 7 years ago

cbowman0 commented 7 years ago

Can someone else confirm that setting graphType=pie on a render URL results in the following error?

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/graphite/webapp/graphite/render/views.py", line 377, in renderView
    image = doImageRender(requestOptions['graphClass'], graphOptions)
  File "/opt/graphite/webapp/graphite/render/views.py", line 630, in doImageRender
    img = graphClass(**graphOptions)
  File "/opt/graphite/webapp/graphite/render/glyph.py", line 577, in __init__
    self.drawGraph(**params)
  File "/opt/graphite/webapp/graphite/render/glyph.py", line 1803, in drawGraph
    self.drawLegend(elements)
  File "/opt/graphite/webapp/graphite/render/glyph.py", line 712, in drawLegend
    longestName = sorted([e[0] for e in elements],key=len)[-1]
IndexError: list index out of range

I'm testing out the current 1.0.x branch and noticed this error when attempting to load a dashboard with pie charts on it. I don't think anything in my local changes or deployment should cause this.

cbowman0 commented 7 years ago

Graphs work if I set REMOTE_PREFETCH_DATA = False.

DanCech commented 7 years ago

Sounds like an issue with the code that checks whether the remote data was prefetched or not

cbowman0 commented 7 years ago

It looks like the prefetch code is buried under the elif requestOptions['graphType'] == 'line': section in webapp/graphite/render/views.py

DanCech commented 7 years ago

Yes, but the code that does the actual fetches should see that it wasn't prefetched and fetch it normally, regardless of the prefetch setting

cbowman0 commented 7 years ago

I don't see where that would happen. Should it be in datalib.py's fetchData or _fetchData?

cbowman0 commented 7 years ago

Making this change gets pie charts back to working: https://github.com/cbowman0/graphite-web/commit/1510d0afb587d5746876f032b5fcf4004fb64c78