Bailey did this one time when he was young. I could tell that he was in pain so I rushed him to the ER vet. Turned out he had eaten some sticks in the yard which had become impacted.
If he is pooping okay, I would just keep an eye on him and keep an eye on his poop (a mother's job is never done
). If he is not able to poop, or seems to have difficulty, then take him to the vet.