← Back to team overview

graphite-dev team mailing list archive

[Question #198404]: Use pickle protocol through rubypython

 

New question #198404 on Graphite:
https://answers.launchpad.net/graphite/+question/198404

Hi, 
I'm currently using graphite in for a Ruby on Rails app, we would like to pass batches of metrics to carbon via the pickle protocol, but knowing it's on python, I decided to use the RubyPython gateway. Here's my code, 

      RubyPython.start
      stats= "[(path,(#{2.months.ago.to_i}, 10000))]"
      cPickle = RubyPython.import 'cPickle'
      serialized_stats = cPickle.dumps(stats, protocol=-1)
      struct = RubyPython.import 'struct'
      length = serialized_stats.rubify.length.to_i
      puts length
      header = struct.pack("!L", length)
      message =  header + serialized_stats
      socket.write(message)
      RubyPython.stop
      socket.close

Everything works fine, no errors in the ruby side, but in the carbon-cache server I get this error

25/05/2012 12:42:05 :: [console] Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/twisted/python/log.py", line 84, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/site-packages/twisted/python/log.py", line 69, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/site-packages/twisted/internet/selectreactor.py", line 150, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "/usr/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 199, in doRead
    rval = self.protocol.dataReceived(data)
  File "/usr/local/lib/python2.7/site-packages/twisted/protocols/basic.py", line 755, in dataReceived
    self.stringReceived(packet)
  File "/opt/graphite/lib/carbon/protocols.py", line 93, in stringReceived
    for (metric, datapoint) in datapoints:

hope anyone can give me a clue to solve this
thanks!!!

-- 
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.