Mathematica calls it a 'stadium' shape
https://reference.wolfram.com/language/ref/StadiumShape.html
The perimeter of a general stadium
StadiumShape[{{x1, y1}, {x2, y2}}, r]
can be obtained using:
ArcLength[RegionBoundary[StadiumShape[{{x1, y1}, {x2, y2}}, r]]]
giving:
2 (Pi r + Sqrt[(x1-x2)^2+(y1-y2)^2])
To calculate the length of the wire just calculate the area (perimeter times depth). And divide by the diameter of the wire.
- For thick wire you have to compensate for 'lost' space.
- For slightly better accuracy you could add the radius of the wire to the radius of the stadium shape to account for the finite thickness of the wire.