Nebo15 / logger_json

JSON logger formatter with support for Google Cloud, DataDog and other for Elixir.
https://nebo15.github.io/logger_json/
MIT License
237 stars 92 forks source link

App not passing FQDNs to datadog. #97

Closed rparcus closed 6 months ago

rparcus commented 1 year ago

We noticed that :inet.gethostname() is not sending fully qualified domain names to datadog. A simple fix would be to use :net_adm.localhost() and the --name option.

iex(app@corp-7220.us-central1-c.c.corp-integ-0.internal)3> :inet.gethostname()
{:ok, 'corp-7220'}
iex(app@corp-7220.us-central1-c.c.corp-integ-0.internal)4> :net_adm.localhost()
'corp-7220.us-central1-c.c.corp-integ-0.internal'

We can have a PR swapping the two functions and call it a day. Would you see any drawbacks in abandoning :inet.gethostname/0?

cc: @rudebono

AndrewDryga commented 1 year ago

I think this issue is already solved in one of the recent releases, take a look: https://github.com/Nebo15/logger_json/pull/87. You can override the hostname with any value reading it from the system environment or just avoid setting it and let DataDog agent to put it for you.

FYI: The problem with swapping them is that not everyone is using --name option and even :net_adm.localhost() is not reliable in some cases, for example for our production environment results for both of those functions are precisely the same and not a FQDN:

iex(talkinto-domain@10-3-0-14.talkinto.pod.cluster.local)1> :inet.gethostname()
{:ok, 'talkinto-workers-messaging-5f7996c66f-n9t5s'}
iex(talkinto-domain@10-3-0-14.talkinto.pod.cluster.local)2> :net_adm.localhost()
'talkinto-workers-messaging-5f7996c66f-n9t5s'
rparcus commented 1 year ago

There are some limitations for which those two options do not work for us. Would adding a config that allows users to pick between :inet.gethostname() and :net_adm.localhost() be ok?

AndrewDryga commented 6 months ago

This can be set in the current version using the hostname option of the formatter.