Skip to content

service.name is set to None because of elasticapm_service_name #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Atheuz opened this issue Oct 11, 2021 · 3 comments · Fixed by #67
Closed

service.name is set to None because of elasticapm_service_name #66

Atheuz opened this issue Oct 11, 2021 · 3 comments · Fixed by #67
Assignees
Labels
agent-python bug Something isn't working

Comments

@Atheuz
Copy link

Atheuz commented Oct 11, 2021

Hi,

If you have an application that adds a key like this to its log:

{"service": {"version": 1.0.0, "name": "myapp", "environment": "dev"}}

Then you end up having service.name be set to None and ultimately be deleted from the output, because of this line:

extras["service.name"] = extras.pop("elasticapm_service_name", None)

Maybe this should instead set service.name to prefer elasticapm_service_name, but fall back to service.name if it already exists and isn't None, i.e.:

extras["service.name"] = extras.pop("elasticapm_service_name", extras.get("service.name", None))

I'm not using Elastic APM and ran into this issue.

@beniwohli
Copy link

Great find @Atheuz! Another option would be

extras.setdefault("service.name", extras.pop("elasticapm_service_name", None))

This would only set "service.name" if it isn't set already. Maybe it would even be a good idea to check for the presence of any of the five fields that we get from Elastic APM, and only set them if none of them are set already. This would avoid a confusing scenario where only some of the ECS fields are from Elastic APM, but not all. What do you think @sethmlarson @basepi?

@sethmlarson
Copy link
Contributor

@beniwohli Definitely agree that .setdefault() is way better than an unconditional __setitem__, I'm ++ on your suggestion.

@basepi
Copy link
Contributor

basepi commented Oct 12, 2021

This should be fixed in #67

@basepi basepi added the bug Something isn't working label Oct 12, 2021
@basepi basepi self-assigned this Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants