You'll get the proxy that you measure but often not the actual productivity that you were hoping for.
Lines of code is a terrible public metric, but that does not mean you can't quietly monitor it, see outliers and then look at it qualitatively without ever mentioning the triggering metric is lines of code?
An example is the folks that generate enormous lift by enabling others to produce better faster delivery in the code base. They work relentlessly but never change code. They’re the most valuable engineer you have, and are frankly in my experience what a 10x engineer must be. Are they unproductive? How do you measure their contribution?
The only answer is by watching them work and understanding the team dynamic and just letting them do what magic they do.
But this is actually hard work for managers and requires introspection and empathy most managers lack. Most managers are there to monitor widget production, promote people along the level guidance by the metrics, report status to their managers, and give delivery timelines based on all this. These managers strangle engineering by their attempts to measure.
I call this the Heisenberg uncertainty principle of software engineering.
the problem is this ridiculous notion that a software manager shouldn't know anything at all about software. how long do you think a construction foreman would last if they new nothing about construction.
Individual managers can do that, but it doesn't scale to an organization. Someone is going to spill the beans on what metrics you're looking at.
Managers generally are incentivized for their team to look good on whatever metrics the organization is watching, so they are going to push their team to work to the metric, possibly even to the point of telling what the secret metric is.
And not for individual engineers, but whole teams.