簡體   English   中英

Azure AppInsights未記錄服務器響應時間

[英]Azure AppInsights is not logging Server Response Time

我們正在使用“ Microsoft.ApplicationInsights 2.1.0.0”並安裝了appinsight塊軟件包。 已經配置的應用程序。 我可以看到PAGE VIEW,SERVER REQUEST和FAILED REQUEST。 但是我沒有在Azure門戶中看到任何服務器響應時間。 如果我向下鑽取,則可以看到“操作名稱”。 是否有任何遺漏的東西。

  public void LogTrace(string message, Dictionary<string,string> dict)
    {
         TelemetryClient.TrackTrace(message,dict);
    }

    public void LogHttpRequest(string Name,DateTime CreatedDateTime,TimeSpan Duration,string ResponseCode,bool flag)
    {
        TelemetryClient.TrackRequest(Name, CreatedDateTime, Duration, ResponseCode, flag);           
    }

private void LogMessage(string message, SeverityLevel traceSeverity, string title)
    {
       TelemetryClient.TrackTrace(title, traceSeverity, null);
    } 



public void LogMetrics(string PageName, double totalDuration)
    {
   TelemetryClient.TrackMetric(new MetricTelemetry(PageName, totalDuration));
    }

 public void LogCustomEvent(string message, Dictionary<string, string> extendedInformation, Dictionary<string, double> metrics)
    {
        TelemetryClient.TrackEvent(message, extendedInformation, metrics);
    }

public void LogException(Exception ex, string APPNAME)
    {
        var additonal = new Dictionary<string, string>();
        additonal.Add(APPNAME,APPNAME );
        TelemetryClient.TrackException(ex, new Dictionary<string, string>()
           {
                { "Exception Message", ex.Message },
                { "Exception Source", ex.Source },
                { "CallStack",ex.StackTrace??String.Empty}
           }, new Dictionary<string, double>()
            {
                { "Total HTTP Exceptions", 1 }
            });         
    }

有什么我想念的東西嗎,原因是我們看不到任何服務器響應時間。

根據您的代碼,我假設您正在使用Application Insights API進行自定義指標。 我檢查了TrackRequest並使用以下代碼記錄HTTP請求,如下所示:

TelemetryClient client = new TelemetryClient()
{
    InstrumentationKey = "{your-Instrumentation-Key}"
};
client.TrackRequest(new RequestTelemetry()
{
    Name = "/api/values",
    StartTime = DateTime.UtcNow,
    Duration = TimeSpan.FromSeconds(2),
    ResponseCode = "200",
    Success = true
});

結果:

在此處輸入圖片說明

在此處輸入圖片說明

總之,請確保您的事件類型正確並且可以包含持續時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM