Ejemplo n.º 1
0
        /// <summary>
        /// Use to monitor certain quantitative values at certain interval.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="metricName">The metric name</param>
        /// <param name="metricValue">Corresponding metric value</param>
        public void TrackMetric(string eventSource, string correlationClientTrackingId, string metricName, double metricValue)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(SeverityLevel.Informational, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                Dictionary <string, object> trackMetrics = new Dictionary <string, object>
                {
                    { Constants.OMSTrackingAPIConstants.SourceEventSourceName, eventSource },
                    { $"{Constants.OMSTrackingAPIConstants.SourceRunInstance}{Constants.OMSTrackingAPIConstants.OmsCorrelationTrackingId}", correlationClientTrackingId },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{metricName}", metricValue }
                };

                this.dataCollector.Collect(this.LogType, trackMetrics);
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Similar to event viewer. Filter out the events based on <paramref name="severityLevel"/> is what we are interested in here.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="message">The message to be displayed</param>
        /// <param name="severityLevel">The severity level</param>
        /// <param name="properties">The properties to be added along with the message</param>
        public void TrackTrace(string eventSource, string correlationClientTrackingId, string message, SeverityLevel severityLevel, IDictionary <string, object> properties)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(severityLevel, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                Dictionary <string, object> trackTraces = new Dictionary <string, object>
                {
                    { Constants.OMSTrackingAPIConstants.SourceEventSourceName, eventSource },
                    { $"{Constants.OMSTrackingAPIConstants.SourceRunInstance}{Constants.OMSTrackingAPIConstants.OmsCorrelationTrackingId}", correlationClientTrackingId },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsEventLevel}", severityLevel.ToString() },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsMesssage}", message }
                };

                foreach (KeyValuePair <string, object> property in properties)
                {
                    trackTraces.Add($"{Constants.OMSTrackingAPIConstants.EventRecord}{property.Key}", property.Value);
                }

                this.dataCollector.Collect(this.LogType, trackTraces);
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Similar to event viewer. Filter out the events based on <paramref name="severityLevel"/> is what we are interested in here.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="message">The message to be displayed</param>
        /// <param name="severityLevel">The severity level</param>
        public void TrackTrace(string eventSource, string correlationClientTrackingId, string message, SeverityLevel severityLevel)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(severityLevel, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                Dictionary <string, object> properties = new Dictionary <string, object>
                {
                    { Constants.IntegrationAccountTrackingApiConstants.OmsMesssage, message }
                };

                this.managementEndPoint.PostCustomTrackingEvents(
                    eventSource,
                    correlationClientTrackingId,
                    severityLevel.ToString(),
                    DateTime.UtcNow.ToString("O"),
                    new Dictionary <string, object>(),
                    properties);
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Use to monitor certain quantitative values at certain interval.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="metricName">The metric name</param>
        /// <param name="metricValue">Corresponding metric value</param>
        public void TrackMetric(string eventSource, string correlationClientTrackingId, string metricName, double metricValue)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(SeverityLevel.Informational, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                this.managementEndPoint.PostCustomTrackingEvents(
                    eventSource,
                    correlationClientTrackingId,
                    SeverityLevel.Informational.ToString(),
                    DateTime.UtcNow.ToString("O"),
                    new Dictionary <string, object>(),
                    new Dictionary <string, object>()
                {
                    { metricName, metricValue }
                });
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Use to track certain events. The count of the events is what we are interested in here.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="eventName">The event name</param>
        public void TrackEvent(string eventSource, string correlationClientTrackingId, string eventName)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(SeverityLevel.Informational, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                this.managementEndPoint.PostCustomTrackingEvents(
                    eventSource,
                    correlationClientTrackingId,
                    SeverityLevel.Informational.ToString(),
                    DateTime.UtcNow.ToString("O"),
                    new Dictionary <string, object>(),
                    new Dictionary <string, object>()
                {
                    { Constants.IntegrationAccountTrackingApiConstants.OmsEventName, eventName }
                });
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Use to track exceptions. The frequency of the exception and examining their individual occurrences is what we are interested in here.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="message">The message to be displayed</param>
        /// <param name="severityLevel">The severity level</param>
        /// <param name="exception">The exception</param>
        public void TrackException(string eventSource, string correlationClientTrackingId, string message, SeverityLevel severityLevel, Exception exception)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(severityLevel, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                Dictionary <string, object> trackedExceptions = new Dictionary <string, object>
                {
                    { Constants.IntegrationAccountTrackingApiConstants.OmsCorrelationTrackingId, correlationClientTrackingId },
                    { Constants.IntegrationAccountTrackingApiConstants.OmsMesssage, message },
                    { Constants.IntegrationAccountTrackingApiConstants.OmsSeverityLevel, severityLevel.ToString() },
                    { Constants.IntegrationAccountTrackingApiConstants.OmsExceptionType, exception.GetType().ToString() },
                    { Constants.IntegrationAccountTrackingApiConstants.OmsExceptionMesssage, exception.Message },
                    { Constants.IntegrationAccountTrackingApiConstants.OmsExceptionStackTrace, exception.StackTrace }
                };

                var aggregateException = exception as AggregateException;
                if (aggregateException != null)
                {
                    var i = 0;
                    foreach (Exception innerException in aggregateException.InnerExceptions)
                    {
                        trackedExceptions.Add($"{Constants.IntegrationAccountTrackingApiConstants.OmsInnerExceptionType}_{i}", innerException.GetType().ToString());
                        trackedExceptions.Add($"{Constants.IntegrationAccountTrackingApiConstants.OmsInnerExceptionMesssage}_{i}", innerException.Message);
                        trackedExceptions.Add($"{Constants.IntegrationAccountTrackingApiConstants.OmsInnerExceptionStackTrace}_{i}", innerException.StackTrace);
                        i++;
                    }
                }

                this.managementEndPoint.PostCustomTrackingEvents(
                    eventSource,
                    correlationClientTrackingId,
                    severityLevel.ToString(),
                    DateTime.UtcNow.ToString("O"),
                    new Dictionary <string, object>(),
                    trackedExceptions);
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Use to track exceptions. The frequency of the exception and examining their individual occurrences is what we are interested in here.
        /// </summary>
        /// <param name="eventSource">The event source name</param>
        /// <param name="correlationClientTrackingId">The correlation tracking id of the workflow run</param>
        /// <param name="message">The message to be displayed</param>
        /// <param name="severityLevel">The severity level</param>
        /// <param name="exception">The exception</param>
        public void TrackException(string eventSource, string correlationClientTrackingId, string message, SeverityLevel severityLevel, Exception exception)
        {
            if (!SeverityLevelHelper.IsAllowedForLogging(severityLevel, this.MimimumLogginglevel))
            {
                return;
            }

            try
            {
                Dictionary <string, object> trackedExceptions = new Dictionary <string, object>
                {
                    { Constants.OMSTrackingAPIConstants.SourceEventSourceName, eventSource },
                    { $"{Constants.OMSTrackingAPIConstants.SourceRunInstance}{Constants.OMSTrackingAPIConstants.OmsCorrelationTrackingId}", correlationClientTrackingId },
                    { $"{Constants.OMSTrackingAPIConstants.Event}{Constants.OMSTrackingAPIConstants.OmsEventLevel}", severityLevel.ToString() },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsMesssage}", message },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsExceptionType}", exception.GetType().ToString() },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsExceptionMesssage}", exception.Message },
                    { $"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsExceptionStackTrace}", exception.StackTrace }
                };

                var aggregateException = exception as AggregateException;
                if (aggregateException != null)
                {
                    var i = 0;
                    foreach (Exception innerException in aggregateException.InnerExceptions)
                    {
                        trackedExceptions.Add($"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsInnerExceptionType}_{i}", innerException.GetType().ToString());
                        trackedExceptions.Add($"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsInnerExceptionMesssage}_{i}", innerException.Message);
                        trackedExceptions.Add($"{Constants.OMSTrackingAPIConstants.EventRecord}{Constants.OMSTrackingAPIConstants.OmsInnerExceptionStackTrace}_{i}", innerException.StackTrace);
                        i++;
                    }
                }

                this.dataCollector.Collect(this.LogType, trackedExceptions);
            }
            catch (Exception)
            {
                if (this.ThrowTrackingException)
                {
                    throw;
                }
            }
        }