Beispiel #1
0
        /// <summary>
        /// Calls the <see cref="ISpecificAutocollectedMetricsExtractor.ExtractMetrics(ITelemetry, out Boolean)"/> of each participating extractor for the specified item.
        /// Catches and logs all errors.
        /// If <c>isItemProcessed</c> is True, adds a corresponding marker to the item's properties.
        /// </summary>
        /// <param name="fromItem">The item from which to extract metrics.</param>
        private void ExtractMetrics(ITelemetry fromItem)
        {
            ISupportSampling potentiallySampledItem = fromItem as ISupportSampling;

            if (potentiallySampledItem != null && false == this.EnsureItemNotSampled(potentiallySampledItem))
            {
                return;
            }

            for (int e = 0; e < this.extractors.Length; e++)
            {
                ExtractorWithInfo participant = this.extractors[e];
                try
                {
                    bool isItemProcessed;
                    participant.Extractor.ExtractMetrics(fromItem, out isItemProcessed);

                    if (isItemProcessed)
                    {
                        AddExtractorInfo(fromItem, participant.Info);
                    }
                }
                catch (Exception ex)
                {
                    CoreEventSource.Log.LogError("Extraction error in " + participant.Extractor.GetType().Name + ": " + ex.ToString());
                }
            }
        }
Beispiel #2
0
        private bool EnsureItemNotSampled(ISupportSampling item)
        {
            if (item.SamplingPercentage.HasValue &&
                item.SamplingPercentage.Value < (100.0 - 1.0E-12))
            {
                if (false == this.isMetricExtractorAfterSamplingLogged)
                {
                    //// benign race
                    this.isMetricExtractorAfterSamplingLogged = true;
                    CoreEventSource.Log.MetricExtractorAfterSamplingError();
                }
                else
                {
                    CoreEventSource.Log.MetricExtractorAfterSamplingVerbose();
                }

                return(false);
            }

            return(true);
        }
        private bool EnsureItemNotSampled(ITelemetry item)
        {
            ISupportSampling potentiallySampledItem = item as ISupportSampling;

            if (potentiallySampledItem != null &&
                potentiallySampledItem.SamplingPercentage.HasValue &&
                potentiallySampledItem.SamplingPercentage.Value < (100.0 - 1.0E-12))
            {
                if (!this.isMetricExtractorAfterSamplingLogged)
                {
                    //// benign race
                    this.isMetricExtractorAfterSamplingLogged = true;
                    CoreEventSource.Log.MetricExtractorAfterSamplingError();
                }
                else
                {
                    CoreEventSource.Log.MetricExtractorAfterSamplingVerbose();
                }

                return(false);
            }

            return(true);
        }
Beispiel #4
0
 private static void CopySamplingFields(Telemetry inputTelemetry, ISupportSampling telemetry)
 {
     telemetry.SamplingPercentage = null; // inputTelemetry.SamplingRate?.Value; always sample (if configured), regardless of whether it was sampled previousely on the client
 }
 private static void CopySamplingFields(Telemetry inputTelemetry, ISupportSampling telemetry)
 {
     telemetry.SamplingPercentage = inputTelemetry.SamplingRate?.Value ?? 100;
 }