Example #1
0
        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();
        }
        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();
        }
Example #3
0
 /// <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);
 }
Example #4
0
 /// <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);
 }
Example #5
0
 /// <summary>
 /// Reports an perf event on how long something took.
 /// </summary>
 /// <param name="eventName"></param>
 public void ReportPerfEvent(object component, string eventName, TimeSpan timeTaken)
 {
     TelemetryClient client = new TelemetryClient();
     client.TrackMetric(component.GetType().Name + ":" + eventName, timeTaken.TotalMilliseconds);
 }
 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 });
 }
Example #7
0
 /// <summary>
 /// Log and track custom app insights metrics with global common properities
 /// See https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/#api-summary
 /// </summary>
 /// <param name="metricName"></param>
 /// <param name="value"></param>
 /// <param name="properties"></param>
 internal static void TrackMetric(string metricName, double value, IDictionary <string, string> properties)
 {
     // add common properties
     AddCommonProperties(ref properties);
     _TelemetryClient.TrackMetric(metricName, value, properties);
 }
Example #8
0
        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();
        }
Example #9
0
        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();
        }
Example #10
0
 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);
 }
        private async Task RefreshCalendar()
        {
            var sw = Stopwatch.StartNew();

            var calendarService = new CalendarService(
                ApplicationDataController.GetValue(KeyNames.CalendarServiceUrl, string.Empty));

            var allAppointments = new List<Appointment>();
            foreach (var calendarId in ApplicationDataController.GetValue(KeyNames.CalendarIdentifiers, new string[] { }))
            {
                var calendar = await calendarService.GetCalendar(calendarId);
                if (calendar == null)
                    continue;
                allAppointments.AddRange(calendar.Appointments);
            }

            // We are displaying appointments for the next 7 days.
            var days = new Dictionary<DateTime, List<Appointment>>
            {
                {TimeManager.Today, new List<Appointment>()},
                {TimeManager.Today.AddDays(1), new List<Appointment>()},
                {TimeManager.Today.AddDays(2), new List<Appointment>()},
                {TimeManager.Today.AddDays(3), new List<Appointment>()},
                {TimeManager.Today.AddDays(4), new List<Appointment>()},
                {TimeManager.Today.AddDays(5), new List<Appointment>()},
                {TimeManager.Today.AddDays(6), new List<Appointment>()},
            };

            foreach (var appointment in allAppointments)
            {
                if (days.ContainsKey(appointment.StartTime.Date))
                {
                    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);
            });

        }
 protected void Page_Load(object sender, EventArgs e)
 {
     var telemetry = new TelemetryClient(TelemetryConfiguration.Active);
     telemetry.TrackMetric("MetricTracker", 0.01);
 }
 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);
 }