Skip to content

Commit

Permalink
semantic convention 1.20.0 verification - database instrumentation - …
Browse files Browse the repository at this point in the history
  • Loading branch information
cBiscuitSurprise committed Sep 1, 2023
1 parent a02d98c commit 1b4c88d
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,23 @@ def test_no_op_tracer_provider(self):

spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)

def test_db_semantic_attributes_server(self):
redis_client = redis.Redis()
connection = redis.connection.Connection()
redis_client.connection = connection

with mock.patch.object(redis_client, "connection"):
redis_client.set("key", "value")

spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 1)

span = spans[0]
self.assertEqual(span.name, "SET")
self.assertEqual(span.attributes.get("db.system"), "redis")
self.assertEqual(span.attributes.get("net.peer.name"), "localhost")
self.assertEqual(span.attributes.get("net.peer.port"), 6379)
self.assertEqual(span.attributes.get("net.transport"), "ip_tcp")
self.assertEqual(span.attributes.get("db.redis.database_index"), 0)
self.assertEqual(span.attributes.get("db.statement"), "SET ? ?")

0 comments on commit 1b4c88d

Please sign in to comment.