"You have another chance, not only in terms of what this court can give you . . . Make the most of it," Common Pleas Judge Benjamin Lerner advised Gonzalez.
He then sentenced her to two years' reporting probation, mandatory drug testing and ordered her to take parenting classes.
Assistant District Attorney Mark Levenberg, who did not contest the sentence, told Lerner that Gonzalez has a 2010 conviction in Delaware County for conspiracy to possess a controlled substance.
"Obviously, through her conduct, she put her child in jeopardy," Levenberg said. "But for the fact the defendant is pregnant again, I would ask for a period of incarceration."
Public defender Daniel Stevenson said Gonzalez is back with the father of her late son and is "living a normal life."
Joseph Zysk, 28, the ex-boyfriend, is awaiting trial for third-degree murder in the Jan. 15, 2011 beating death of Jason Larkin, 3.
While Gonzalez and the boy were sleeping over at the Roxborough home of Zysk's mother, he told police, he struck the child multiple times when he wouldn't stop crying.
Jason suffered a lacerated liver and died from multiple blunt-force trauma and internal bleeding. Gonzalez had been using heroin that night, Levenberg said.