Skip to content

Commit f631a26

Browse files
authored
feat: add db.operation attribute for dalli (#458)
1 parent 55f52c4 commit f631a26

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/patches/server.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def request(op, *args) # rubocop:disable Naming/MethodParameterName
1414
operation = Utils.opname(op, multi?)
1515
attributes = {
1616
'db.system' => 'memcached',
17+
'db.operation' => operation,
1718
'net.peer.name' => hostname,
1819
'net.peer.port' => port
1920
}

instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
_(span.name).must_equal 'set'
5151
_(span.attributes['db.system']).must_equal 'memcached'
5252
_(span.attributes['db.statement']).must_equal 'set foo bar 0 0'
53+
_(span.attributes['db.operation']).must_equal 'set'
5354
_(span.attributes['net.peer.name']).must_equal host
5455
_(span.attributes['net.peer.port']).must_equal port
5556
end
@@ -61,6 +62,7 @@
6162
_(span.name).must_equal 'get'
6263
_(span.attributes['db.system']).must_equal 'memcached'
6364
_(span.attributes['db.statement']).must_equal 'get foo'
65+
_(span.attributes['db.operation']).must_equal 'get'
6466
_(span.attributes['net.peer.name']).must_equal host
6567
_(span.attributes['net.peer.port']).must_equal port
6668
end
@@ -72,6 +74,7 @@
7274
_(span.name).must_equal 'getkq'
7375
_(span.attributes['db.system']).must_equal 'memcached'
7476
_(span.attributes['db.statement']).must_equal 'getkq foo bar'
77+
_(span.attributes['db.operation']).must_equal 'getkq'
7578
_(span.attributes['net.peer.name']).must_equal host
7679
_(span.attributes['net.peer.port']).must_equal port
7780
end
@@ -93,6 +96,7 @@
9396
_(span.name).must_equal 'getkq'
9497
_(span.attributes['db.system']).must_equal 'memcached'
9598
_(span.attributes['db.statement']).must_equal 'getkq foo bar'
99+
_(span.attributes['db.operation']).must_equal 'getkq'
96100
_(span.attributes['net.peer.name']).must_equal host
97101
_(span.attributes['net.peer.port']).must_equal port
98102

0 commit comments

Comments
 (0)