Skip to content

Commit c7b08f3

Browse files
committed
Include exception information for failed statements.
1 parent 7d725aa commit c7b08f3

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

sqlalchemy_opentracing/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ def _engine_error_handler(exception_context):
171171
if span is None:
172172
return
173173

174+
exc = exception_context.original_exception
175+
span.set_tag('sqlalchemy.exception', str(exc))
174176
span.set_tag('error', 'true')
175177
span.finish()
176178

tests/test_core.py

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def test_traced_error(self):
7474
'db.statement': 'CREATE TABLE users (id INTEGER NOT NULL, name VARCHAR, PRIMARY KEY (id))',
7575
'db.type': 'sql',
7676
'sqlalchemy.dialect': 'sqlite',
77+
'sqlalchemy.exception': 'table users already exists',
7778
'error': 'true',
7879
})
7980

tests/test_orm.py

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_traced_error(self):
9393
'db.statement': 'INSERT INTO users (id, name) VALUES (?, ?)',
9494
'db.type': 'sql',
9595
'sqlalchemy.dialect': 'sqlite',
96+
'sqlalchemy.exception': 'UNIQUE constraint failed: users.id',
9697
'error': 'true',
9798
})
9899

0 commit comments

Comments
 (0)