ApplicationInsights-Go icon indicating copy to clipboard operation
ApplicationInsights-Go copied to clipboard

Failed to resolve domain/ silently failed to track within WSL2

Open untoldone opened this issue 3 years ago • 1 comments

I haven't been able to completely investigate this / understand the root causes, but I'm opening an issue here in case anyone else hits the same problem as I suspect its a common setup to use Go within WSL2 with Application Insights.

At first, I wasn't seeing any events make it to my Application Insights instance so I had to add a diagnostic listener via NewDiagnosticsMessageListener -- that showed the following message:

Failed to transmit telemetry: Post "https://dc.services.visualstudio.com/v2/track": dial tcp: lookup dc.services.visualstudio.com on 172.30.208.1:53: cannot unmarshal DNS message

When outside the application dig dc.services.visualstudio.com would resolve the domain correctly. While researching this I came across the similar https://github.com/rclone/rclone/issues/4984 in which the project member @ncw created the upstream issue https://github.com/golang/go/issues/44135 (appears to have been automatically closed without research / assignment).

A work around for this issue is to set the environment variable GODEBUG=netdns=cgo when running/ building your application.

I'd be ok if this is seen as not related to this project, but given it seems there's no one pursuing the upstream fix, it will cause this library to fail silently without really giving any hints that the library isn't working which seems a noteworthy usability issue which at a minimum I would think should be documented here given the likelihood of this lib being used with WSL.

untoldone avatar Oct 28 '21 22:10 untoldone

Thanks for this note. As @jboelter has mentioned, this appears to be related to an upstream issue. The silent failure is unfortunately a side-effect of asynchronous transmission, though I'm glad you were able to detect it from the diagnostic messages.

jjjordanmsft avatar Nov 08 '21 22:11 jjjordanmsft