示例#1
0
        /// <summary>
        /// Invoke this method when the cmdlet is completed or terminated.
        /// </summary>
        protected void LogQosEvent()
        {
            if (_qosEvent == null)
            {
                return;
            }

            _qosEvent.FinishQosEvent();

            if (!IsUsageMetricEnabled && (!IsErrorMetricEnabled || _qosEvent.IsSuccess))
            {
                return;
            }

            if (!IsDataCollectionAllowed())
            {
                return;
            }

            WriteDebug(_qosEvent.ToString());

            try
            {
                _metricHelper.SetPSHost(this.Host);
                _metricHelper.LogQoSEvent(_qosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
                _metricHelper.FlushMetric();
                WriteDebug("Finish sending metric.");
            }
            catch (Exception e)
            {
                //Swallow error from Application Insights event collection.
                WriteWarning(e.ToString());
            }
        }
示例#2
0
        /// <summary>
        /// Invoke this method when the cmdlet is completed or terminated.
        /// </summary>
        protected void LogQosEvent(bool waitForMetricSending = false)
        {
            if (QosEvent == null)
            {
                return;
            }

            QosEvent.FinishQosEvent();

            if (!IsUsageMetricEnabled && (!IsErrorMetricEnabled || QosEvent.IsSuccess))
            {
                return;
            }

            if (!IsDataCollectionAllowed())
            {
                return;
            }

            WriteDebug(QosEvent.ToString());

            try
            {
                MetricHelper.LogQoSEvent(QosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
                MetricHelper.FlushMetric(waitForMetricSending);
                WriteDebug("Finish sending metric.");
            }
            catch (Exception e)
            {
                //Swallow error from Application Insights event collection.
                WriteWarning(e.ToString());
            }
        }
示例#3
0
        /// <summary>
        /// Log a telemtry event
        /// </summary>
        /// <param name="qosEvent">The event to log</param>
        public void LogEvent(AzurePSQoSEvent qosEvent)
        {
            var dataCollection = _dataCollectionProfile.EnableAzureDataCollection;
            var enabled        = dataCollection.HasValue ? dataCollection.Value : true;

            _helper.LogQoSEvent(qosEvent, enabled, enabled);
        }