public TelemetryDispatcher(TelemetrySink sink, bool cloneBeforeDispatch)
 {
     Debug.Assert(sink != null, "Telemetry sink should not be null");
     this.sink = sink;
     this.cloneBeforeDispatch    = cloneBeforeDispatch;
     this.nextTelemetryToProcess = null;
 }
 public override void Track(ITelemetry telemetryItem)
 {
     if (TelemetrySink != null)
     {
         this.Initialize(telemetryItem);
         TelemetrySink.Process(telemetryItem);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TelemetryProcessorChainBuilder" /> class.
        /// </summary>
        /// <param name="configuration">Configuration instance to use for constructing the processor chain.</param>
        /// <param name="telemetrySink">Telemetry sink the processor chain will be assigned to.</param>
        public TelemetryProcessorChainBuilder(TelemetryConfiguration configuration, TelemetrySink telemetrySink) : this(configuration)
        {
            if (telemetrySink == null)
            {
                throw new ArgumentNullException(nameof(telemetrySink));
            }

            this.telemetrySink = telemetrySink;
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransmissionProcessor"/> class.
        /// </summary>
        /// <param name="sink">The <see cref="TelemetrySink"/> holding to the telemetry channel to use for sending telemetry.</param>
        internal TransmissionProcessor(TelemetrySink sink)
        {
            if (sink == null)
            {
                throw new ArgumentNullException(nameof(sink));
            }

            this.sink = sink;
        }
Exemple #5
0
        public PassThroughProcessor(TelemetrySink sink)
        {
            if (sink == null)
            {
                throw new ArgumentNullException(nameof(sink));
            }

            this.sink = sink;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TransmissionProcessor"/> class.
        /// </summary>
        /// <param name="sink">The <see cref="TelemetrySink"/> holding to the telemetry channel to use for sending telemetry.</param>
        internal TransmissionProcessor(TelemetrySink sink)
        {
            if (sink == null)
            {
                throw new ArgumentNullException(nameof(sink));
            }

            this.sink        = sink;
            this.debugOutput = PlatformSingleton.Current.GetDebugOutput();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TelemetryProcessorChainBuilder" /> class.
        /// </summary>
        /// <param name="configuration"> The <see cref="TelemetryConfiguration"/> instance to which the constructed processing chain should be set to.</param>
        public TelemetryProcessorChainBuilder(TelemetryConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.configuration = configuration;
            this.factories     = new List <Func <ITelemetryProcessor, ITelemetryProcessor> >();
            this.telemetrySink = null;
        }
Exemple #8
0
        private void SetupMocksAndSink(bool multipleMockTargets)
        {
            _telemetryMock1 = new Mock <ITelemetry>(MockBehavior.Strict);
            _telemetryMock2 = new Mock <ITelemetry>(MockBehavior.Strict);

            if (multipleMockTargets)
            {
                _telemetrySink = new TelemetrySink(new[] { _telemetryMock1.Object, _telemetryMock2.Object }, true);
            }
            else
            {
                _telemetrySink = new TelemetrySink(new[] { _telemetryMock1.Object }, true);
            }
        }
        private static void AddGenevaSink(IServiceCollection services, AppInsightsSettings settings)
        {
            var config = new TelemetryConfiguration {
                InstrumentationKey = GetInstrumentationKey(settings)
            };

            TelemetryConfiguration genevaMdsdConfig = new TelemetryConfiguration(settings.Geneva.OneDSSinkChannel);
            TelemetrySink          mdsdSink         = new TelemetrySink(config, new GenevaAgentChannel())
            {
                Name = settings.Geneva.OneDSSinkChannel
            };

            mdsdSink.Initialize(genevaMdsdConfig);
            config.TelemetrySinks.Add(mdsdSink);
            config.TelemetryProcessorChainBuilder.Use(next => new GenevaMetricsProcessor(next)
            {
                MetricAccountName = settings.Geneva.GenevaMetricsAccountName,
                MetricNamespace   = settings.Geneva.GenevaMetricsNamespace
            });
            config.TelemetryProcessorChainBuilder.Build();
            Console.WriteLine($"Added geneva metrics sink, account={settings.Geneva.GenevaMetricsAccountName}, namespace={settings.Geneva.GenevaMetricsNamespace}");

            services.AddSingleton(config);
        }
Exemple #10
0
        public void IsEnabled_TelemetryIsNull_ReturnsFalse()
        {
            TelemetrySink sink = new TelemetrySink(null);

            Assert.IsFalse(sink.IsEnabled);
        }
Exemple #11
0
 public void BeforeEachTest()
 {
     _telemetryMock = new Mock <ITelemetry>(MockBehavior.Strict);
     _telemetrySink = new TelemetrySink(_telemetryMock.Object);
 }
Exemple #12
0
        public void IsEnabled_TelemetryIsDisabledByGroupPolicy_ReturnsFalse()
        {
            TelemetrySink sink = new TelemetrySink(new[] { _telemetryMock1.Object }, false);

            Assert.IsFalse(sink.IsEnabled);
        }
Exemple #13
0
        public void IsEnabled_NoTelemetryClassesExist_ReturnsFalse()
        {
            TelemetrySink sink = new TelemetrySink(new List <ITelemetry>(), true);

            Assert.IsFalse(sink.IsEnabled);
        }