Skip to content

Commit 8c876e2

Browse files
committed
fix: compact Dalli attributes
1 parent 8320ded commit 8c876e2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def request(op, *args) # rubocop:disable Naming/MethodParameterName
1717
'db.operation' => operation,
1818
'net.peer.name' => hostname,
1919
'net.peer.port' => port
20-
}
20+
}.compact
2121
if config[:db_statement] == :include
2222
attributes['db.statement'] = Utils.format_command(operation, args)
2323
elsif config[:db_statement] == :obfuscate

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@
4444
_(span.attributes['peer.service']).must_equal 'readonly:memcached'
4545
end
4646

47+
it 'supports unix domain socket' do
48+
dalli.version
49+
50+
server = dalli.instance_variable_get(:@ring).servers.first
51+
server.stub(:hostname, '/tmp/memcached.sock') do
52+
server.stub(:port, nil) do
53+
dalli.set('foo', 'bar')
54+
55+
_(exporter.finished_spans.size).must_equal 1
56+
_(span.name).must_equal 'set'
57+
_(span.attributes).wont_include 'net.peer.port'
58+
_(span.attributes['net.peer.name']).must_equal '/tmp/memcached.sock'
59+
end
60+
end
61+
end
62+
4763
it 'before request' do
4864
_(exporter.finished_spans.size).must_equal 0
4965
end

0 commit comments

Comments
 (0)