Raygun with Jython
Aziza
Posted on
Jun 16 2016
Attached is the email thread with one of the Raygun developers about the issue of using Raygun with a Jython script. The basic code for what I want to do is also attached.
Callum
Posted on
Jun 16 2016
Hi again,
As mentioned in that private ticket, a work item to add guard code for Jython not matching cpython's environment spec is scheduled, and we will reply to you via intercom when this is complete.
Regards,
Callum Gavin
Raygun Limited
Aziza
Posted on
Jun 18 2016
Hi Callum,
Thanks for the efficiency. I think I'm one step closer to getting what I need. So now the object is not being effectively serialized after being sent. This is the current error: Traceback (most recent call last): File "raytest.py", line 11, in exception() File "/usr/lib/python2.6/site-packages/raygun4py/raygunprovider.py", line 110, in sendexception return self.post(message) File "/usr/lib/python2.6/site-packages/raygun4py/raygunprovider.py", line 156, in post json = jsonpickle.encode(raygunMessage, unpicklable=False) File "/usr/lib/python2.6/site-packages/jsonpickle/init.py", line 125, in encode return pickler.encode(value, File "/usr/lib/python2.6/site-packages/jsonpickle/pickler.py", line 42, in encode return backend.encode(context.flatten(value, reset=reset)) File "/usr/lib/python2.6/site-packages/jsonpickle/backend.py", line 165, in encode raise e TypeError: {'occurredOn': u'2016-06-17 12:39:01.459000', 'details': {'version': u'Not defined', 'client': {'version': u'3.1.3', 'clientUrl': u'https://github.com/MindscapeHQ/raygun4py', 'name': u'raygun4py'}, 'tags': None, 'environment': {'processorCount': u'n/a', 'cpu': u'x8664', 'environmentVariables': None, 'architecture': u'64bit', 'runtimeVersion': u'Python 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) \n[OpenJDK 64-Bit Server VM (Oracle Corporation)]', 'oSVersion': u'Java 1.7.095', 'runtimeLocation': None}, 'groupingKey': None, 'error': {'message': u'IndexError: index out of range: 0', 'className': u'IndexError', 'globalVariables': None, 'data': u'', 'stackTrace': [{'localVariables': {'client': u'test.py', 'name': u'main', 'package': u'None', 'list': u'[]', 'raygunprovider': u"
The script now looks like this: import sys sys.path.append('/usr/lib/python2.6/site-packages')
from raygun4py import raygunprovider
client = raygunprovider.RaygunSender("") try: list = [] print list[0]
except Exception: client.send_exception()
Callum
Posted on
Jun 22 2016
Can you try replacing your RaygunSender instantiation with this:
client = raygunprovider.RaygunSender('your_apikey', config={
'transmit_global_variables': False,
'transmit_local_variables': False
})
That should avoid the exception in jsonpickle.
As a side note if that doesn't work, are you able to install and use Jython 2.7? Python encoding and serialization in 2.x is error prone at the best of times, and for Jython it looks like we're running up against bugs in std libraries that don't exist in for cpython. As such if possible it would be greatly beneficial to use the latest release, for both bug and security fixes as Python 2.6 last had its final security release 3 years ago and as such looks no longer maintained.
If the above suggested fix doesn't work, please try it with 2.7.
Aziza
Posted on
Jun 23 2016
I have been using Jython 2.7 actually and even altering the RaygunSender gives the same error above mentioned, I was using conflicting versions of Jython and python because jython doesn't have a 2.6 version and I was using python 2.6 but changed my python version to 2.7 to accommodate the jython 2.7 version and still the same error..
Callum
Posted on
Jun 28 2016
Hi again,
I've had time to take a deeper dive into this, and have identified a further issue with the local variable guard code. I've pushed additional commits to the jython-env-fix branch and the unit tests and regression tests now pass as expected. If you pull down the latest commits on that branch and run
pip install . --upgrade
that should get the sending working as expected.