Skip to content

Commit

Permalink
fix(specs): Latest redis clients might skip db index in server URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraichen committed Jul 10, 2024
1 parent 8fbcc6b commit e7287f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions spec/mnemosyne/probes/redis-client/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
trace.span[0].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'HELLO ?'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end

trace.span[1].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'SET mykey ?'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end

trace.span[2].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'GET mykey'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end
end

Expand All @@ -60,14 +60,14 @@
trace.span[0].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'HELLO ?'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end

trace.span[1].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq "SET foo ?\nSET baz ?"
expect(span.meta[:pipelined]).to eq true
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end
end

Expand All @@ -83,14 +83,14 @@
trace.span[0].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'HELLO ?'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end

trace.span[1].tap do |span|
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'UNKNOWN_FUNCTION ?'
expect(span.meta[:error]).to start_with 'ERR unknown command'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379'
end
end
end
12 changes: 6 additions & 6 deletions spec/mnemosyne/probes/redis/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
span = trace.span[0]
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'SET mykey ?'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to match %r{^redis://127.0.0.1:16379(/0)?$}

span = trace.span[1]
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'GET mykey'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to match %r{^redis://127.0.0.1:16379(/0)?$}
end

it 'creates just one span for pipelined (parallel) commands' do
Expand All @@ -51,7 +51,7 @@
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq "SET foo ?\nSET baz ?"
expect(span.meta[:pipelined]).to eq true
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to match %r{^redis://127.0.0.1:16379(/0)?$}
end

it 'traces queued commands (also run in parallel when committing)' do
Expand All @@ -74,7 +74,7 @@
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq "SET mykey ?\nSET foo ?"
expect(span.meta[:pipelined]).to eq true
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to match %r{^redis://127.0.0.1:16379(/0)?$}
end

it 'traces commands queued with array syntax' do
Expand All @@ -97,7 +97,7 @@
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq "SET mykey ?\nSET foo ?"
expect(span.meta[:pipelined]).to eq true
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to match %r{^redis://127.0.0.1:16379(/0)?$}
end

it 'attaches errors to the span' do
Expand All @@ -113,6 +113,6 @@
expect(span.name).to eq 'db.query.redis'
expect(span.meta[:commands]).to eq 'UNKNOWN_FUNCTION ?'
expect(span.meta[:error]).to start_with 'ERR unknown command'
expect(span.meta[:server]).to eq 'redis://127.0.0.1:16379/0'
expect(span.meta[:server]).to match %r{^redis://127.0.0.1:16379(/0)?$}
end
end

0 comments on commit e7287f4

Please sign in to comment.