diff options
author | Zuul <zuul@review.openstack.org> | 2018-12-22 03:34:15 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2018-12-22 03:34:15 +0000 |
commit | 97564b644f0446d03f8fab92632c84e9b2e43dec (patch) | |
tree | 8208bf5aeecf176e86c0c15bb0b7693d2354cc0c | |
parent | 8ae3f4aee8f5146bf581f67557cd5a005fa1e706 (diff) | |
parent | de5f31650e21b340cbac9499152f6ff8db3a14fa (diff) | |
download | osprofiler-97564b644f0446d03f8fab92632c84e9b2e43dec.tar.gz |
Merge "In case of an error, always add message"2.5.2
-rw-r--r-- | osprofiler/profiler.py | 6 | ||||
-rw-r--r-- | osprofiler/sqlalchemy.py | 1 | ||||
-rw-r--r-- | osprofiler/tests/unit/test_profiler.py | 2 | ||||
-rw-r--r-- | osprofiler/tests/unit/test_sqlalchemy.py | 1 |
4 files changed, 8 insertions, 2 deletions
diff --git a/osprofiler/profiler.py b/osprofiler/profiler.py index 1290f51..3748c16 100644 --- a/osprofiler/profiler.py +++ b/osprofiler/profiler.py @@ -17,6 +17,7 @@ import collections import datetime import functools import inspect +import six import socket import threading @@ -158,7 +159,10 @@ def trace(name, info=None, hide_args=False, hide_result=True, start(name, info=info_) result = f(*args, **kwargs) except Exception as ex: - stop_info = {"etype": reflection.get_class_name(ex)} + stop_info = { + "etype": reflection.get_class_name(ex), + "message": six.text_type(ex) + } raise else: if not hide_result: diff --git a/osprofiler/sqlalchemy.py b/osprofiler/sqlalchemy.py index 2118adc..5e2fc3c 100644 --- a/osprofiler/sqlalchemy.py +++ b/osprofiler/sqlalchemy.py @@ -105,6 +105,7 @@ def handle_error(exception_context): info = { "etype": exception_class_name, + "message": original_exception, "db": { "original_exception": original_exception, "chained_exception": chained_exception diff --git a/osprofiler/tests/unit/test_profiler.py b/osprofiler/tests/unit/test_profiler.py index 00dcd0f..fbe0ccd 100644 --- a/osprofiler/tests/unit/test_profiler.py +++ b/osprofiler/tests/unit/test_profiler.py @@ -260,7 +260,7 @@ class TraceDecoratorTestCase(test.TestCase): "name": "osprofiler.tests.unit.test_profiler.test_fn_exc" } } - expected_stop_info = {"etype": "ValueError"} + expected_stop_info = {"etype": "ValueError", "message": ""} mock_start.assert_called_once_with("foo", info=expected_info) mock_stop.assert_called_once_with(info=expected_stop_info) diff --git a/osprofiler/tests/unit/test_sqlalchemy.py b/osprofiler/tests/unit/test_sqlalchemy.py index 0b20aa5..3ccf6bf 100644 --- a/osprofiler/tests/unit/test_sqlalchemy.py +++ b/osprofiler/tests/unit/test_sqlalchemy.py @@ -62,6 +62,7 @@ class SqlalchemyTracingTestCase(test.TestCase): sqlalchemy.handle_error(sqlalchemy_exception_ctx) expected_info = { "etype": "Exception", + "message": "error", "db": { "original_exception": str(original_exception), "chained_exception": str(chained_exception), |