logger_json icon indicating copy to clipboard operation
logger_json copied to clipboard

App not passing FQDNs to datadog.

Open rparcus opened this issue 3 years ago • 2 comments

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([email protected])3> :inet.gethostname()
{:ok, 'corp-7220'}
iex([email protected])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

rparcus avatar Oct 20 '22 02:10 rparcus

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([email protected])1> :inet.gethostname()
{:ok, 'talkinto-workers-messaging-5f7996c66f-n9t5s'}
iex([email protected])2> :net_adm.localhost()
'talkinto-workers-messaging-5f7996c66f-n9t5s'

AndrewDryga avatar Oct 21 '22 03:10 AndrewDryga

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?

rparcus avatar Oct 21 '22 07:10 rparcus

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

AndrewDryga avatar Apr 11 '24 23:04 AndrewDryga