For pendulum applications where temperature-induced length changes are of concern, you need to be measuring atmospheric pressure and temperature anyway to do corrections related to air damping. If the environment is a confined space where significant changes to air composition are possible, you'll need a gas analyzer too.
So, you already should have a solid ambient air temperature measurement. From that you derive the length of the rod. You can also instrument the rod with a 4-wire Pt-100 temperature sensor. I've seen it done using 4 rods in parallel, each used as a conductor, with the Pt-100 sensor mounted on one of them, with tiny wires connecting it to the other rods.
But in any case, the temperature is an excellent proxy for thermal expansion. You can characterize the pendulum beam for thermal mass and thermal resistance to ambient air, to compensate for dT/dt at least to the first order.
If the rod is long and significantly loaded by the pendulum weight, then you'll also be making non-linear corrections due to dynamic stretching of the rod (centripetal force it exerts on the weight).
So, I'd say - if you have to worry about temperature, then you have to worry about all that other stuff too, since it all falls within an order of magnitude of each other, design-dependent of course.
It will be a pendulum.
Is this for a museum display or an educational demo? I'm at a bit of a loss as to what one would use a pendulum for in a professional capacity otherwise...
But in any case: all this seems like a problem for a metrologist. The electrical engineering end of things is the simplest. A proper metrological error analysis will inform what you must measure, and how to best measure it using measurement devices available.
The question to be off-topic here, since without a metrological analysis to substantiate that you absolutely must measure physical length and nothing else will do... it's a classic XY problem. I would go as far as saying that a proper analysis will tell you that you do not need to measure the actual length of the rod.