This should work:
var text = $("#my_svg #container_svg_ToolTipText_4");
var width = text.innerWidth();
var rect = $("#my_svg #container_svg_SvgRect");
rect.attr("width", width + 10);
If you set the x value of the rect to be 5 units less than the x unit of the text, it will be centred. Set the y value of the rect to be ~10 units less than the y unit of the text or calculate the height of the text using innerHeight
.