Skip to content

Commit 531df87

Browse files
Add db.system attribute
1 parent c1c173f commit 531df87

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def _wrap_connect_internal(func, module, args, kwargs):
9595
if span.is_recording():
9696
attrs, _ = _get_attributes_from_url(module.url)
9797
span.set_attributes(attrs)
98+
span.set_attribute(SpanAttributes.DB_SYSTEM, _normalize_vendor(module.name))
9899
return func(*args, **kwargs)
99100

100101
return _wrap_connect_internal

instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def test_create_engine_wrapper(self):
162162
# first span - the connection to the db
163163
self.assertEqual(spans[0].name, "connect")
164164
self.assertEqual(spans[0].attributes[SpanAttributes.DB_NAME], ":memory:")
165+
self.assertEqual(spans[0].attributes[SpanAttributes.DB_SYSTEM], "sqlite")
165166
self.assertEqual(spans[0].kind, trace.SpanKind.CLIENT)
166167
# second span - the query
167168
self.assertEqual(spans[1].name, "SELECT :memory:")
@@ -221,6 +222,7 @@ async def run():
221222
# first span - the connection to the db
222223
self.assertEqual(spans[0].name, "connect")
223224
self.assertEqual(spans[0].attributes[SpanAttributes.DB_NAME], ":memory:")
225+
self.assertEqual(spans[0].attributes[SpanAttributes.DB_SYSTEM], "sqlite")
224226
self.assertEqual(spans[0].kind, trace.SpanKind.CLIENT)
225227
# second span - the query
226228
self.assertEqual(spans[1].name, "SELECT :memory:")

0 commit comments

Comments
 (0)