![](/img/trans.png)
[英]Is there story of supporting php and azure application insights in 2021?
[英]Display specific PHP files in Application Insights
我們將一個非常古老的php應用程序遷移到Azure,我們通過Web App選項激活了Application Insights。
現在我們確定一些非常高的請求持續時間(> 15s),但我們無法識別哪些php文件負責。
在具體的操作信息中我們只看到domain.com/folder/而不是相應的php文件。
我們必須配置什么來查看哪個文件(= function => domain.com/folder/myfile.php)負責這個糟糕的舊PHP應用程序?
我們已經在開發中替換這個本機Azure功能的應用程序,但我們現在需要一個過渡修復。
謝謝
同意@Mike Oryszak ,您需要編寫代碼以在代碼中收集自定義事件。
為此,您只需在代碼中安裝應用程序洞察即可
$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();
通過調用以下方法,您可以在AI遙測中記錄任何消息。
$telemetryClient->trackEvent('name of your event');
以下是如何使用自定義屬性發送自定義遙測。
$telemetryClient->trackEvent('name of your event', ['MyCustomProperty' => 42, 'MyCustomProperty2' => 'test'], ['duration', 42]);
發送請求遙測項目,包括持續時間,http狀態代碼,請求是否成功,自定義屬性和測量。這似乎是您的最佳選擇。
$telemetryClient->trackRequest('myRequest', 'http://foo.bar', time(), 3754, 200, true, ['InlineProperty' => 'test_value'], ['duration_inner' => 42.0]);
你可以在這里尋找更多樣品。
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.