当前位置: 首页>>代码示例>>C#>>正文


C# TelemetryClient.TrackMetric方法代码示例

本文整理汇总了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();
        }
开发者ID:girish,项目名称:NuGet.Jobs,代码行数:18,代码来源:ApplicationInsights.cs

示例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();
        }
开发者ID:darrelmiller,项目名称:NuGet.Services.Search,代码行数:22,代码来源:Startup.cs

示例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);
 }
开发者ID:Arthur-Lee,项目名称:Baconit,代码行数:10,代码来源:TelemetryManager.cs

示例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);
 }
开发者ID:Arthur-Lee,项目名称:Baconit,代码行数:10,代码来源:TelemetryManager.cs

示例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 });
 }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:5,代码来源:TestMetricForm.aspx.cs

示例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();
        }
开发者ID:girish,项目名称:NuGet.Jobs,代码行数:18,代码来源:ApplicationInsights.cs

示例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();
        }
开发者ID:girish,项目名称:NuGet.Jobs,代码行数:18,代码来源:ApplicationInsights.cs

示例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);
 }
开发者ID:agangal,项目名称:TrackMyActV2,代码行数:21,代码来源:MainPage.xaml.cs

示例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);
            });

        }
开发者ID:nicklasjepsen,项目名称:MagicPiMirror,代码行数:101,代码来源:MainPage.xaml.cs

示例10: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     var telemetry = new TelemetryClient(TelemetryConfiguration.Active);
     telemetry.TrackMetric("MetricTracker", 0.01);
 }
开发者ID:gregjhogan,项目名称:ApplicationInsights-server-dotnet,代码行数:5,代码来源:TestMetricForm.aspx.cs

示例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);
 }
开发者ID:RickIsWright,项目名称:ApplicationInsights-Home,代码行数:9,代码来源:PingClient.cs


注:本文中的Microsoft.ApplicationInsights.TelemetryClient.TrackMetric方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。