Skip to content

Commit

Permalink
Consolidate redis span data
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Sep 5, 2023
1 parent 3be7f22 commit 4ab0076
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def self.subscribe!
connection.pool.spec.config
end

span.set_data(Span::DataConventions::DB_NAME, db_config[:database]) if db_config[:database]
span.set_data(Span::DataConventions::DB_SYSTEM, db_config[:adapter]) if db_config[:adapter]
span.set_data(Span::DataConventions::DB_NAME, db_config[:database]) if db_config[:database]
span.set_data(Span::DataConventions::SERVER_ADDRESS, db_config[:host]) if db_config[:host]
span.set_data(Span::DataConventions::SERVER_PORT, db_config[:port]) if db_config[:port]
span.set_data(Span::DataConventions::SERVER_SOCKET_ADDRESS, db_config[:socket]) if db_config[:socket]
Expand Down
5 changes: 4 additions & 1 deletion sentry-ruby/lib/sentry/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def instrument

if span
span.set_description(commands_description)
span.set_data(:server, server_description)
span.set_data(Span::DataConventions::DB_SYSTEM, "redis")
span.set_data(Span::DataConventions::DB_NAME, db)
span.set_data(Span::DataConventions::SERVER_ADDRESS, host)
span.set_data(Span::DataConventions::SERVER_PORT, port)
end
end
end
Expand Down
7 changes: 6 additions & 1 deletion sentry-ruby/spec/sentry/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
expect(request_span.timestamp).not_to be_nil
expect(request_span.start_timestamp).not_to eq(request_span.timestamp)
expect(request_span.description).to eq("SET key value")
expect(request_span.data).to eq({ server: "127.0.0.1:6379/0" })
expect(request_span.data).to eq({
"db.name" => 0,
"db.system" => "redis",
"server.address" => "127.0.0.1",
"server.port" => 6379
})
end

it "removes bad encoding keys and arguments gracefully" do
Expand Down

0 comments on commit 4ab0076

Please sign in to comment.