Reputation: 3035
We are using "Microsoft.ApplicationInsights 2.1.0.0" and installed appinsight nugget packages. Already configured application. I could see PAGE VIEW, SERVER REQUEST & FAILED REQUEST. But i dont see any Server Response TIME in Azure portal. If i drill-down, i could see OPERATION NAME. Is there any thing missing.
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 }
});
}
Is there any thing which I'm missing, that reason we couldn't see any server response time.
Upvotes: 0
Views: 618
Reputation: 18465
Based on your code, I assumed that you are using Application Insights API for custom metrics. I checked TrackRequest and used the following code for logging HTTP request as follows:
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
});
RESULT:
In summary, please make sure your event type is correct and could contain the duration.
Upvotes: 3