microsoft / ApplicationInsights-PHP

Azure Application Insights SDK for PHP
https://azure.microsoft.com/services/application-insights/
Other
108 stars 92 forks source link

Server / Browser exception #25

Closed turowicz closed 6 years ago

turowicz commented 7 years ago

Hi

Currently all my exceptions are reported as Browser Exceptions, but obviously PHP errors are Server Exceptions, which means something is either wrong with the AI client, or I'm using it incorrectly.

My code is as simple as:

$this->telemetryClient->trackException($e, ['message' => $formatted]);
$this->telemetryClient->flush();
JakubOleksy commented 7 years ago

It is definitely a server exception. Is it possible you are also using the JS library and getting client exceptions from there?

turowicz commented 7 years ago

Not possible as I haven't included any AI JS scripts in the project.

EDIT: Also the exception stack traces I get are strictly backend.

AlexBulankou commented 7 years ago

@turowicz, when you look in Analytics UI what device_type are are seeing for these exceptions?

turowicz commented 7 years ago

@AlexBulankou it says Device Type: PC. Can it be because the devices calling the service don't report User-Agent? We're saving GSM data bandwitdth, it's an IoT system.

AlexBulankou commented 7 years ago

@turowicz device_type:PC is actually correct, I was expecting browser, which would explain the issue. If this is ok with you, let's please take this offline, so I will ask if you can more details about your app. Can you please email me at albulank@microsoft.com. Thank you!

AlexBulankou commented 7 years ago

@turowicz haven't heard from you on this, are you still experiencing the issue? Thanks!

turowicz commented 7 years ago

@AlexBulankou hey, the problem still there, sorry I was busy with other things and didn't check this thread. I will pop you an email.

SergeyKanzhelev commented 6 years ago

I believe this code is at fault:

https://github.com/Microsoft/ApplicationInsights-PHP/blob/634d0af2a4e10be6e4886cec6c560b4cb38911ae/ApplicationInsights/Channel/Telemetry_Channel.php#L192-L195

It sets the User-Agent on post request being send to the server. It indicates to Application Insights endpoint that the call is from client application, not from the server.