예제 #1
0
 /// <summary>
 /// Sends an event with the specified duration added as a measurement
 /// </summary>
 /// <param name="eventName">The name of the event</param>
 /// <param name="durationMs">The duration of the event</param>
 /// <param name="properties">Any other properties to send with the event</param>
 /// <param name="measurements">Any other measurements to send with the event</param>
 public void TrackDuration(TelemetryEventName eventName, long durationMs, IDictionary <string, string> properties = null,
                           IDictionary <string, double> measurements = null)
 {
     try
     {
         measurements ??= new Dictionary <string, double>();
         measurements.Add(TelemetryMeasureName.DurationMs.ToString(), durationMs);
         this.TrackEvent(eventName, properties, measurements);
     }
     catch (Exception ex)
     {
         // We don't want errors sending telemetry to break the app, so just log and move on
         Debug.Fail($"Error sending event {eventName} : {ex.Message}");
     }
 }
예제 #2
0
        public void TrackEvent(TelemetryEventName eventName, IDictionary <string, string> properties = null,
                               IDictionary <string, double> measurements = null)
        {
            try
            {
                if (!this._initialized || !this.Enabled)
                {
                    return;
                }
                this._logger.LogInformation($"Sending event {eventName}");

                //continue task in existing parallel thread
                this._trackEventTask = this._trackEventTask.ContinueWith(
                    x => this.TrackEventTask(eventName.ToString(), properties, measurements)
                    );
            }
            catch (Exception ex)
            {
                // We don't want errors sending telemetry to break the app, so just log and move on
                Debug.Fail($"Error sending event {eventName} : {ex.Message}");
            }
        }