简体   繁体   English

在Application Insights中显示特定的PHP文件

[英]Display specific PHP files in Application Insights

We migrated a very old php application to Azure and we have activated Application Insights via the Web App option. 我们将一个非常古老的php应用程序迁移到Azure,我们通过Web App选项激活了Application Insights。

Now we identify some very high request durations (>15s) but we cannot identify which php files are responsible. 现在我们确定一些非常高的请求持续时间(> 15s),但我们无法识别哪些php文件负责。

In the specific operation information we only see domain.com/folder/ but not the corresponding php file. 在具体的操作信息中我们只看到domain.com/folder/而不是相应的php文件。

What do we have to configure to see which file (=function => domain.com/folder/myfile.php) is responsible in this crappy old php app? 我们必须配置什么来查看哪个文件(= function => domain.com/folder/myfile.php)负责这个糟糕的旧PHP应用程序?

We already in development to replace this app which native Azure functionality, but we need a transition fix now. 我们已经在开发中替换这个本机Azure功能的应用程序,但我们现在需要一个过渡修复。

Thanks 谢谢

Agree with @Mike Oryszak , you need to write code to collect custom event in your code. 同意@Mike Oryszak ,您需要编写代码以在代码中收集自定义事件。

For that you can simply install the application insight in your code and then 为此,您只需在代码中安装应用程序洞察即可

$telemetryClient = new \ApplicationInsights\Telemetry_Client();
$context = $telemetryClient->getContext();

// Necessary
$context->setInstrumentationKey('YOUR INSTRUMENTATION KEY');

// Optional
$context->getSessionContext()->setId(session_id());
$context->getUserContext()->setId('YOUR USER ID');
$context->getApplicationContext()->setVer('YOUR VERSION');
$context->getLocationContext()->setIp('YOUR IP');

// Start tracking
$telemetryClient->trackEvent('name of your event');
$telemetryClient->flush();

By calling below method , you can log any message in AI telemetry. 通过调用以下方法,您可以在AI遥测中记录任何消息。

$telemetryClient->trackEvent('name of your event');

Here is how you can send custom telemetry with custom properties. 以下是如何使用自定义属性发送自定义遥测。

$telemetryClient->trackEvent('name of your event', ['MyCustomProperty' => 42, 'MyCustomProperty2' => 'test'], ['duration', 42]);

Sending a request telemetry item with duration, http status code, whether or not the request succeeded, custom properties and measurements.This seems to be the most optimum in your case. 发送请求遥测项目,包括持续时间,http状态代码,请求是否成功,自定义属性和测量。这似乎是您的最佳选择。

$telemetryClient->trackRequest('myRequest', 'http://foo.bar', time(), 3754, 200, true, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);

you can look for more samples here . 你可以在这里寻找更多样品。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM