本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient.TrackMetric方法的典型用法代码示例。如果您正苦于以下问题:C# TelemetryClient.TrackMetric方法的具体用法?C# TelemetryClient.TrackMetric怎么用?C# TelemetryClient.TrackMetric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.ApplicationInsights.TelemetryClient
的用法示例。
在下文中一共展示了TelemetryClient.TrackMetric方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrackMetric
public static void TrackMetric(string metricName, double value, string logFileName)
{
if (!_initialized)
{
return;
}
var telemetryClient = new TelemetryClient();
var telemetry = new MetricTelemetry(metricName, value);
if (!string.IsNullOrWhiteSpace(logFileName))
{
telemetry.Properties.Add("LogFile", logFileName);
}
telemetryClient.TrackMetric(telemetry);
telemetryClient.Flush();
}
示例2: TrackTelemetryOnIndexReopened
private static void TrackTelemetryOnIndexReopened(object sender, SegmentInfoEventArgs e)
{
var telemetryClient = new TelemetryClient();
// track the index reopened event
var eventTelemetry = new EventTelemetry("Index Reopened");
eventTelemetry.Metrics.Add("Segment Count", e.Segments.Count());
eventTelemetry.Metrics.Add("Segment Size (Sum)", e.Segments.Sum(s => s.NumDocs));
telemetryClient.TrackEvent(eventTelemetry);
foreach (var segment in e.Segments)
{
var metricTelemetry = new MetricTelemetry("Segment Size", segment.NumDocs);
metricTelemetry.Properties.Add("Segment Name", segment.Name);
telemetryClient.TrackMetric(metricTelemetry);
}
telemetryClient.Flush();
}
示例3: ReportMetric
/// <summary>
/// Reports a metric event to the telemetry system.
/// </summary>
/// <param name="eventName"></param>
/// <param name="metric"></param>
public void ReportMetric(object component, string eventName, double metric)
{
TelemetryClient client = new TelemetryClient();
client.TrackMetric(component.GetType().Name + ":" + eventName + ":" + eventName, metric);
}
示例4: ReportPerfEvent
/// <summary>
/// Reports an perf event on how long something took. Here you pass the begin
/// time and the delta will be computed
/// </summary>
/// <param name="eventName"></param>
public void ReportPerfEvent(object component, string eventName, DateTime startTime)
{
TelemetryClient client = new TelemetryClient();
client.TrackMetric(component.GetType().Name + ":" + eventName, (DateTime.Now - startTime).TotalMilliseconds);
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var telemetry = new TelemetryClient(TelemetryConfiguration.Active);
telemetry.TrackMetric(new MetricTelemetry() { Name = "MetricTracker", Count = 1, Sum = 0.01 });
}
示例6: TrackReportProcessed
public static void TrackReportProcessed(string reportName, string packageId = null)
{
if (!_initialized)
{
return;
}
var telemetryClient = new TelemetryClient();
var telemetry = new MetricTelemetry(reportName, 1);
if (!string.IsNullOrWhiteSpace(packageId))
{
telemetry.Properties.Add("Package Id", packageId);
}
telemetryClient.TrackMetric(telemetry);
telemetryClient.Flush();
}
示例7: TrackRetrieveDimensionDuration
public static void TrackRetrieveDimensionDuration(string dimension, long value, string logFileName)
{
if (!_initialized)
{
return;
}
var telemetryClient = new TelemetryClient();
var telemetry = new MetricTelemetry("Retrieve Dimension duration (ms)", value);
telemetry.Properties.Add("Dimension", dimension);
if (!string.IsNullOrWhiteSpace(logFileName))
{
telemetry.Properties.Add("LogFile", logFileName);
}
telemetryClient.TrackMetric(telemetry);
telemetryClient.Flush();
}
示例8: updateUI
private void updateUI(RootObjectTrackAct rtact)
{
var tc = new TelemetryClient();
var activityD = rtact.activity;
int i = 0;
foreach (var actv in activityD)
{
if (actv.isDelete == false)
{
activity.Add(actv);
activityPos.Add(actv.name, i);
i++;
}
}
//var timedata = rtrackact.activity[0].timer_data;
//foreach (var tdata in timedata)
//{
// tmdata.Add(tdata);
//}
tc.TrackMetric("Number of Activities", rtact.activity.Count);
}
示例9: RefreshCalendar
//.........这里部分代码省略.........
{
days[appointment.StartTime.Date].Add(appointment);
}
else
{
LogError("Appointment occurring on day that we can't display. Appointment StartDate=" +
appointment.StartTime);
}
}
await RunOnDispatch(() =>
{
for (var i = 0; i < days.Count; i++)
{
var currentDay = TimeManager.Today.AddDays(i);
var appointmentsForCurrentDay = days[currentDay];
var heading = (TextBlock)FindName($"Day{i}Txb");
Style appointmentHourStyle = null;
Style appointmentEntryStyle = null;
if (heading == null)
{
LogError("Unable to find the heading textblock for the date " + currentDay);
}
else
{
if (currentDay.Date == TimeManager.Today)
{
heading.Text = Strings.TodaysAgendaHeading;
appointmentHourStyle = (Style)Resources["SmallTextStyle"];
appointmentEntryStyle = (Style)Resources["AppointmentEntryStyleMedium"];
}
else if (currentDay.Date == TimeManager.Today.AddDays(1))
{
appointmentHourStyle = (Style) Resources["AppointmentHourStyle"];
appointmentEntryStyle = (Style) Resources["AppointmentEntryStyle"];
heading.Text = Strings.TomorrowHeading;
}
else
{
appointmentHourStyle = (Style)Resources["AppointmentHourStyle"];
appointmentEntryStyle = (Style)Resources["AppointmentEntryStyle"];
heading.Text = GetDayOfWeek(currentDay.DayOfWeek).ToLower();
}
}
// Set appointments
var daySp = (StackPanel)FindName($"Day{i}Sp");
if (daySp == null)
{
LogError("Unable to find the calendar stack panel for the date " + currentDay);
}
else
{
daySp.Children.Clear();
var appointmentGrouping = appointmentsForCurrentDay
.GroupBy(a => a.StartTime.ToLocalTime().ToString(Strings.CalendarHourGroupByFormatString))
.OrderBy(ag => ag.Key);
if (!appointmentGrouping.Any())
{
daySp.Children.Add(new TextBlock
{
TextTrimming = TextTrimming.WordEllipsis,
Style = appointmentEntryStyle,
Text = Strings.NoAppointments
});
}
else
foreach (var ag in appointmentGrouping)
{
// Group by hour
var hourSp = new StackPanel();
var hourHeadning = ag.Key;
if (hourHeadning.Length < 3)
hourHeadning = hourHeadning + ":00";
hourSp.Children.Add(new TextBlock
{
Style = appointmentHourStyle,
Text = hourHeadning,
});
foreach (var appointment in ag)
{
var entry = new TextBlock
{
TextTrimming = TextTrimming.WordEllipsis,
Style = appointmentEntryStyle,
Text = appointment.Subject
};
hourSp.Children.Add(entry);
}
daySp.Children.Add(hourSp);
}
}
}
var tc = new TelemetryClient();
tc.TrackMetric("Refresh Calendar Time Ms", sw.Elapsed.TotalMilliseconds);
});
}
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var telemetry = new TelemetryClient(TelemetryConfiguration.Active);
telemetry.TrackMetric("MetricTracker", 0.01);
}
示例11: LogPingResult
private static void LogPingResult(PingResult dnsResult, PingResult tcpResult)
{
//Submit metrics to AppInsights for outcome (success=1 / failure=0) and response time for Dns lookup and Tcp port ping
var telemetry = new TelemetryClient();
telemetry.TrackMetric("NetDnsHealth_" + dnsResult.EndPoint.Replace(":", "_") ,dnsResult.IsSuccess);
telemetry.TrackMetric("NetDnsTime_" + dnsResult.EndPoint.Replace(":", "_") ,dnsResult.Value);
telemetry.TrackMetric("NetTcpHealth_" + tcpResult.EndPoint.Replace(":", " ") ,tcpResult.IsSuccess);
telemetry.TrackMetric("NetTcpTime_" + tcpResult.EndPoint.Replace(":", "_") ,tcpResult.Value);
}