The decision has to be made on every player. Some players you bite the bullet on the long term deal into their mid 30s. Other players you trade rather than give them that deal. It's a hard thing to get right, but something that GMs have to consider.
Karlsson is one of the best dmen in the league. If he is still playing at the same level in 2 years, I'm sure Ottawa will re-sign him. Would he sign a 4 or 5 year deal?
Look at what SJ has done with Thornton. His current contract is for 1 year. His last 4 contracts before that were all 3 year deals. He has made roughly the same money on all 4 of those deals and has an even higher AAV on his newest deal. He has continued to play well and has continued to earn big money, but SJ has mitigated their risk by signing him to short term deals.
That's a great model for teams to follow. Maybe you don't sign all of your players to 3 year deals. Obviously you want to lock some up long term, especially good RFAs where you can save some on future caps by going long term, but as a player gets older, shorter term deals are better.
Washington just gave Oshie 8 years at age 30. That's going to be a problem in the future. We've seen way too many players decline in their early 30s.