It appeared there is no issue in the provided code. And the behavior of Datadog platform where service.name attribute is not displayed - is just how the platform works, you can see that on the screenshot in the original question.