Пример #1
0
 public OtpEngine(Action <string> traceMessage, IOtpStoreFactory factory, TelemetryManager telemetryManager, MetricManager metricManager)
 {
     this.traceMessage  = traceMessage;
     this.otpStore      = factory.GetStore();
     this.otpStorage    = telemetryManager;
     this.metricManager = metricManager;
 }
Пример #2
0
 void Start()
 {
     player    = transform.GetComponentInParent <Player>();
     shotTimer = shotTimeLimit;
     LockSign.GetComponent <SpriteRenderer>().enabled = false;
     mm = GameObject.Find("EventSystem").GetComponent <MetricManager>();
 }
Пример #3
0
        public OperationController(
            ISmsStoreFactory factory,
            ServiceConfiguration configuration,
            IReportManager reportManager,
            IInboundManager inboundManager,
            ICredentialManager credentialManager,
            MetricManager metricManager)
        {
            this.store             = factory.GetStore();
            this.configuration     = configuration;
            this.reportManager     = reportManager;
            this.inboundManager    = inboundManager;
            this.credentialManager = credentialManager;
            this.metricManager     = metricManager;

            this.random       = new Random();
            this.proxyFactory = new ServiceProxyFactory((c) =>
            {
                return(new FabricTransportServiceRemotingClientFactory(
                           serializationProvider: new ServiceRemotingJsonSerializationProvider()));
            });

            if (this.configuration.SmsOpsInfo.IsValid())
            {
                this.mailHelper = new MailHelper(this.configuration.SmsOpsInfo);
            }
        }
Пример #4
0
    void Awake()
    {
        //We want to make sure that only one instance of the script
        //exists throughout the game
        //Therefore we destroy any instances created after the first instantiation
        //of the script

        if (Instance != null) //another Instance already exists
        {
            DestroyImmediate(gameObject);
        }
        else //Instance == null - First instantiation of script
        {
            DontDestroyOnLoad(gameObject);
            Instance         = this;
            levelNameToIndex = new Dictionary <string, int>();
            levelNameToIndex.Add("RitualLevel", 0);
            levelNameToIndex.Add("CaveLevel", 1);
            levelNameToIndex.Add("VillageLevel", 2);
            levelNameToIndex.Add("CombatLevel", 3);
            levelNameToIndex.Add("LastLevel", 4);

            levelTimeMetrics    = new int[5];
            levelTimeMetrics[0] = 0;
            levelTimeMetrics[1] = 0;
            levelTimeMetrics[2] = 0;
            levelTimeMetrics[3] = 0;
            levelTimeMetrics[4] = 0;

            deathTypeMetrics    = new int[3];
            deathTypeMetrics[0] = 0; //Fallen
            deathTypeMetrics[1] = 0; //Gem
            deathTypeMetrics[2] = 0; //Spikes
        }
    }
Пример #5
0
 public SocialEngine(Action <string> traceMessage, string connectionString, MetricManager metricManager)
 {
     this.traceMessage     = traceMessage;
     this.storeManager     = new StoreManager(connectionString);
     this.telemetryManager = new TelemetryManager();
     this.metricManager    = metricManager;
 }
Пример #6
0
 void Start()
 {
     player    = transform.GetComponentInParent <Player>();
     shotTimer = 0;
     //rapidCdDisplay.fillAmount = 1;
     mm = GameObject.Find("EventSystem").GetComponent <MetricManager>();
 }
Пример #7
0
        private static MetricManager GetOrCreateMetricManager(TelemetryClient telemetryClient)
        {
            ConditionalWeakTable <TelemetryClient, MetricManager> metricManagers = s_metricManagersForTelemetryClients;

            if (metricManagers == null)
            {
                ConditionalWeakTable <TelemetryClient, MetricManager> newTable  = new ConditionalWeakTable <TelemetryClient, MetricManager>();
                ConditionalWeakTable <TelemetryClient, MetricManager> prevTable = Interlocked.CompareExchange(ref s_metricManagersForTelemetryClients, newTable, null);
                metricManagers = prevTable ?? newTable;
            }

            // Get the manager from the table:
            MetricManager createdManager = null;
            MetricManager chosenManager  = metricManagers.GetValue(
                telemetryClient,
                (tc) =>
            {
                createdManager = new MetricManager(new ApplicationInsightsTelemetryPipeline(tc));
                return(createdManager);
            });

            // If there was a race and we did not end up returning the manager we just created, we will notify it to give up its agregation cycle thread.
            if (createdManager != null && false == Object.ReferenceEquals(createdManager, chosenManager))
            {
                Task fireAndForget = createdManager.StopDefaultAggregationCycleAsync();
            }

            return(chosenManager);
        }
Пример #8
0
        /// <summary>
        /// Stops metric aggregation in advanced scenarios where a MetricManager was explicitly created using its ctor.
        /// </summary>
        /// <remarks>
        /// Metric Manager does not encapsulate any disposable or native resourses. However, it encapsulates a managed thread.
        /// In normal cases, a metric manager is accessed via convenience methods and consumers never need to worry about that thread.
        /// However, advanced scenarios may explicitly create a metric manager instance. In such cases, consumers may need to call
        /// this method on the explicitly created instance to let the thread know that it no longer needs to run. The thread will not
        /// be aborted proactively. Instead, it will complete the ongoing aggregation cycle and then gracfully exit instead of scheduling
        /// the next iteration. However, the background thread will not send any aggregated metrics if it has been notified to stop.
        /// Therefore, this method flushes current data before sending the notification.
        /// </remarks>
        /// <param name="metricManager">The metric manager</param>
        /// <returns>
        /// You can await the returned Task if you want to be sure that the encapsulated thread completed.
        /// If you just want to notify the thread to stop without waiting for it, do not await this method.
        /// </returns>
        public static Task StopDefaultAggregationCycleAsync(this MetricManager metricManager)
        {
            Util.ValidateNotNull(metricManager, nameof(metricManager));

            metricManager.Flush();
            return(metricManager.AggregationCycle.StopAsync());
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="metricManager"></param>
 /// <param name="aggregationCycleKind"></param>
 /// <param name="tactTimestamp"></param>
 /// <returns></returns>
 public static AggregationPeriodSummary StopAggregators(
     this MetricManager metricManager,
     MetricAggregationCycleKind aggregationCycleKind,
     DateTimeOffset tactTimestamp)
 {
     Util.ValidateNotNull(metricManager, nameof(metricManager));
     return(metricManager.AggregationManager.StopAggregators(aggregationCycleKind, tactTimestamp));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="metricManager"></param>
 /// <param name="aggregationCycleKind"></param>
 /// <param name="tactTimestamp"></param>
 /// <param name="futureFilter"></param>
 /// <returns></returns>
 public static AggregationPeriodSummary StartOrCycleAggregators(
     this MetricManager metricManager,
     MetricAggregationCycleKind aggregationCycleKind,
     DateTimeOffset tactTimestamp,
     IMetricSeriesFilter futureFilter)
 {
     Util.ValidateNotNull(metricManager, nameof(metricManager));
     return(metricManager.AggregationManager.StartOrCycleAggregators(aggregationCycleKind, tactTimestamp, futureFilter));
 }
Пример #11
0
 public EmailEngine(
     IEmailStoreFactory factory,
     ServiceConfiguration configuration,
     MetricManager metricManager,
     ICredentialManager credentialManager)
 {
     this.store             = factory.GetStore();
     this.credentialManager = credentialManager;
     this.metricManager     = metricManager;
     this.configuration     = configuration;
 }
        private static void Metrics_SpecifiedPipeline(TelemetryConfiguration telemetryPipeline)
        {
            telemetryPipeline.InstrumentationKey = Guid.NewGuid().ToString("D");

            MetricManager manager1 = telemetryPipeline.GetMetricManager();

            Assert.IsNotNull(manager1);

            MetricManager manager2 = telemetryPipeline.GetMetricManager();

            Assert.IsNotNull(manager2);

            Assert.AreEqual(manager1, manager2);
            Assert.AreSame(manager1, manager2);
            Assert.IsTrue(Object.ReferenceEquals(manager1, manager2));

            StubTelemetryChannel telemetryCollector = new StubTelemetryChannel();

            telemetryPipeline.TelemetryChannel = telemetryCollector;
            Assert.AreSame(telemetryCollector, telemetryPipeline.TelemetryChannel);

            //CollectingTelemetryInitializer telemetryCollector = new CollectingTelemetryInitializer();
            //defaultTelemetryPipeline.TelemetryInitializers.Add(coll);

            IMetricSeriesConfiguration seriesConfig = new MetricSeriesConfigurationForMeasurement(restrictToUInt32Values: false);

            manager1.CreateNewSeries("ns", "Metric A", seriesConfig).TrackValue(42);
            manager1.CreateNewSeries("ns", "Metric A", seriesConfig).TrackValue("18");
            manager2.CreateNewSeries("ns", "Metric A", seriesConfig).TrackValue(10000);
            manager2.CreateNewSeries("ns", "Metric B", seriesConfig).TrackValue(-0.001);
            manager1.Flush();

            Assert.AreEqual(4, telemetryCollector.TelemetryItems.Count);

            Assert.IsInstanceOfType(telemetryCollector.TelemetryItems[0], typeof(MetricTelemetry));
            Assert.AreEqual("Metric B", ((MetricTelemetry)telemetryCollector.TelemetryItems[0]).Name);
            Assert.AreEqual(1, ((MetricTelemetry)telemetryCollector.TelemetryItems[0]).Count);
            Assert.AreEqual(-0.001, ((MetricTelemetry)telemetryCollector.TelemetryItems[0]).Sum);

            Assert.IsInstanceOfType(telemetryCollector.TelemetryItems[1], typeof(MetricTelemetry));
            Assert.AreEqual("Metric A", ((MetricTelemetry)telemetryCollector.TelemetryItems[1]).Name);
            Assert.AreEqual(1, ((MetricTelemetry)telemetryCollector.TelemetryItems[1]).Count);
            Assert.AreEqual(10000, ((MetricTelemetry)telemetryCollector.TelemetryItems[1]).Sum);

            Assert.IsInstanceOfType(telemetryCollector.TelemetryItems[2], typeof(MetricTelemetry));
            Assert.AreEqual("Metric A", ((MetricTelemetry)telemetryCollector.TelemetryItems[2]).Name);
            Assert.AreEqual(1, ((MetricTelemetry)telemetryCollector.TelemetryItems[2]).Count);
            Assert.AreEqual(18, ((MetricTelemetry)telemetryCollector.TelemetryItems[2]).Sum);

            Assert.IsInstanceOfType(telemetryCollector.TelemetryItems[3], typeof(MetricTelemetry));
            Assert.AreEqual("Metric A", ((MetricTelemetry)telemetryCollector.TelemetryItems[3]).Name);
            Assert.AreEqual(1, ((MetricTelemetry)telemetryCollector.TelemetryItems[3]).Count);
            Assert.AreEqual(42, ((MetricTelemetry)telemetryCollector.TelemetryItems[3]).Sum);
        }
        private static Metric GetOrCreateMetric(
            TelemetryClient telemetryClient,
            MetricAggregationScope aggregationScope,
            MetricIdentifier metricIdentifier,
            MetricConfiguration metricConfiguration)
        {
            Util.ValidateNotNull(telemetryClient, nameof(telemetryClient));

            MetricManager metricManager = telemetryClient.GetMetricManager(aggregationScope);
            Metric        metric        = metricManager.Metrics.GetOrCreate(metricIdentifier, metricConfiguration);

            return(metric);
        }
Пример #14
0
    void Awake()
    {
//		DontDestroyOnLoad (transform.gameObject);
        if (Instance == null)
        {
            DontDestroyOnLoad(gameObject);
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Пример #15
0
        StopAggregators(
            object metricManager,
            int aggregationCycleKind,
            DateTimeOffset tactTimestamp)
        {
            MetricManager manager            = (MetricManager)metricManager;
            MetricAggregationCycleKind cycle = SafeConvertMetricAggregationCycleKind(aggregationCycleKind);

            AggregationPeriodSummary summary = MetricManagerExtensions.StopAggregators(manager, cycle, tactTimestamp);

            var result = Tuple.Create(summary.NonpersistentAggregates, summary.PersistentAggregates);

            return(result);
        }
Пример #16
0
    void Start()
    {
        spawnRatio = idealRatio;

        StartCoroutine(SpawnWords());
        collider = GetComponent <CircleCollider2D>();
        audio    = GetComponent <AudioSource>();
        stored   = FindObjectOfType <ScoreKeeper>();
        stored.StartMeditation();
        fade = FindObjectOfType <Fading>();
        ps   = GetComponent <ParticleSystem>();

        metrics = GameObject.Find("ScoreKeeper").GetComponent <MetricManager>();
        metrics.AddToAttempts(1);
    }
Пример #17
0
        static void Main(string[] args)
        {
            var metricManager = new MetricManager(new MetricsManagerHelpers());
            var metrics       = metricManager.GetOsMetrics();

            Console.WriteLine();
            Console.WriteLine("****** Mnemox Metrics ********************");
            Console.WriteLine();
            Console.WriteLine($"Memory total(bytes):   {metrics.MemoryCapacityBytes}");
            Console.WriteLine($"Memory used(bytes):    {metrics.MemoryUsedBytes}");
            Console.WriteLine($"Memory used(%):        {metrics.MemoryUsedPercents}");
            Console.WriteLine($"Total CPU usage(%):    {metrics.TotalCpuUsagePercentage}");
            Console.WriteLine($"Process CPU usage(%):  {metrics.CurrentProcessCpuUsagePercentage}");
            Console.WriteLine();
            Console.WriteLine("******************************************");
            Console.WriteLine();
        }
        public void InitializeExtractor(MetricManager metricManager)
        {
            this.responseSuccessTimeMetric = metricManager.CreateMetric(
                MetricTerms.Autocollection.Metric.RequestDuration.Name,
                new Dictionary <string, string>()
            {
                [MetricTerms.Autocollection.Request.PropertyNames.Success] = Boolean.TrueString,
                [MetricTerms.Autocollection.MetricId.Moniker.Key]          = MetricTerms.Autocollection.Metric.RequestDuration.Id,
            });

            this.responseFailureTimeMetric = metricManager.CreateMetric(
                MetricTerms.Autocollection.Metric.RequestDuration.Name,
                new Dictionary <string, string>()
            {
                [MetricTerms.Autocollection.Request.PropertyNames.Success] = Boolean.FalseString,
                [MetricTerms.Autocollection.MetricId.Moniker.Key]          = MetricTerms.Autocollection.Metric.RequestDuration.Id,
            });
        }
Пример #19
0
        StartOrCycleAggregators(
            object metricManager,
            int aggregationCycleKind,
            DateTimeOffset tactTimestamp,
            Func <Tuple <bool,
                         Tuple <Func <object, double, bool>,
                                Func <object, object, bool> > > > metricSeriesFilter)
        {
            MetricManager manager            = (MetricManager)metricManager;
            MetricAggregationCycleKind cycle = SafeConvertMetricAggregationCycleKind(aggregationCycleKind);
            var filter = new MetricSeriesFilterAdapter(metricSeriesFilter);

            AggregationPeriodSummary summary = MetricManagerExtensions.StartOrCycleAggregators(manager, cycle, tactTimestamp, filter);

            var result = Tuple.Create(summary.NonpersistentAggregates, summary.PersistentAggregates);

            return(result);
        }
Пример #20
0
        void MethodX()
        {
            MetricManager manager = TelemetryConfiguration.Active.Metrics();

            IMetricSeriesConfiguration config = new SimpleMetricSeriesConfiguration(restrictToUInt32Values: false);
            MetricSeries series1 = TelemetryConfiguration.Active.Metrics().CreateNewSeries(
                "Cows Sold",
                new Dictionary <string, string> {
                ["Color of Cow"]  = "Red",
                ["Gender of Cow"] = "Female"
            },
                config);

            series1.TrackValue(42);

            series1.TrackValue(1);
            series1.TrackValue(1);
            series1.TrackValue(1);
        }
Пример #21
0
        /// <summary>@ToDo: Complete documentation before stable release. {811}</summary>
        /// <param name="telemetryClient">@ToDo: Complete documentation before stable release. {225}</param>
        /// <param name="aggregationScope">@ToDo: Complete documentation before stable release. {281}</param>
        /// <returns>@ToDo: Complete documentation before stable release. {736}</returns>
        public static MetricManager GetMetricManager(this TelemetryClient telemetryClient, MetricAggregationScope aggregationScope)
        {
            Util.ValidateNotNull(telemetryClient, nameof(telemetryClient));

            switch (aggregationScope)
            {
            case MetricAggregationScope.TelemetryConfiguration:
                TelemetryConfiguration pipeline = telemetryClient.TelemetryConfiguration;
                return(pipeline.GetMetricManager());

            case MetricAggregationScope.TelemetryClient:
                MetricManager manager = GetOrCreateMetricManager(telemetryClient);
                return(manager);

            default:
                throw new ArgumentException(Invariant($"Invalid value of {nameof(aggregationScope)} ({aggregationScope}). Only the following values are supported:")
                                            + Invariant($" ['{nameof(MetricAggregationScope)}.{MetricAggregationScope.TelemetryClient.ToString()}',")
                                            + Invariant($" '{nameof(MetricAggregationScope)}.{MetricAggregationScope.TelemetryConfiguration.ToString()}']."));
            }
        }
        public void Metrics_CustomPipeline()
        {
            ;

            using (TelemetryConfiguration defaultTelemetryPipeline = TelemetryConfiguration.Active)
                using (TelemetryConfiguration customTelemetryPipeline1 = Util.CreateAITelemetryConfig())
                    using (TelemetryConfiguration customTelemetryPipeline2 = Util.CreateAITelemetryConfig())
                    {
                        Assert.IsFalse(Object.ReferenceEquals(defaultTelemetryPipeline, customTelemetryPipeline1));
                        Assert.IsFalse(Object.ReferenceEquals(defaultTelemetryPipeline, customTelemetryPipeline2));
                        Assert.IsFalse(Object.ReferenceEquals(customTelemetryPipeline1, customTelemetryPipeline2));

                        MetricManager managerDef   = defaultTelemetryPipeline.GetMetricManager();
                        MetricManager managerCust1 = customTelemetryPipeline1.GetMetricManager();
                        MetricManager managerCust2 = customTelemetryPipeline2.GetMetricManager();

                        Assert.IsNotNull(managerDef);
                        Assert.IsNotNull(managerCust1);
                        Assert.IsNotNull(managerCust2);

                        Assert.AreNotEqual(managerDef, managerCust1);
                        Assert.AreNotEqual(managerDef, managerCust2);
                        Assert.AreNotEqual(managerCust1, managerCust2);

                        Assert.AreNotSame(managerDef, managerCust1);
                        Assert.AreNotSame(managerDef, managerCust2);
                        Assert.AreNotSame(managerCust1, managerCust2);

                        Assert.IsFalse(Object.ReferenceEquals(managerDef, managerCust1));
                        Assert.IsFalse(Object.ReferenceEquals(managerDef, managerCust2));
                        Assert.IsFalse(Object.ReferenceEquals(managerCust1, managerCust2));

                        Metrics_SpecifiedPipeline(customTelemetryPipeline1);
                        Metrics_SpecifiedPipeline(customTelemetryPipeline2);

                        Util.CompleteDefaultAggregationCycle(managerDef);
                        Util.CompleteDefaultAggregationCycle(managerCust1);
                        Util.CompleteDefaultAggregationCycle(managerCust2);
                    }
        }
Пример #23
0
        public SmsProvider(StatelessServiceContext context)
            : base(context)
        {
            this.configuration = new ServiceConfiguration(FabricRuntime.GetNodeContext(), context.CodePackageActivationContext);
            this.storeFactory  = new SmsStoreFactory(this.configuration.DefaultConnectionString);
            this.billingAgent  = new BillingAgent();
            this.metricManager = new MetricManager(this.configuration);

            // this.timeSeriesManager = this.BuildTimeSeriesManager();

            this.credentialManager = new CredentialManager(this.storeFactory);
            this.reportManager     = new ReportManager(
                this.storeFactory,
                this.configuration,
                this.billingAgent,
                this.metricManager,
                this.credentialManager);
            this.inboundManager = new InboundManager(
                this.storeFactory,
                this.configuration,
                this.reportManager,
                this.credentialManager);
        }
Пример #24
0
        public OperationController(
            IEmailStoreFactory factory,
            IEmailEngine engine,
            ServiceConfiguration configuration,
            IReportManager reportManager,
            ICredentialManager credentialManager,
            MetricManager metricManager)
        {
            this.store         = factory.GetStore();
            this.engine        = engine;
            this.configuration = configuration;

            this.reportManager     = reportManager;
            this.credentialManager = credentialManager;
            this.metricManager     = metricManager;

            this.random       = new Random();
            this.proxyFactory = new ServiceProxyFactory((c) =>
            {
                return(new FabricTransportServiceRemotingClientFactory(
                           serializationProvider: new ServiceRemotingJsonSerializationProvider()));
            });
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="metricManager"></param>
        /// <param name="newExtensionStateInstanceFactory"></param>
        /// <returns></returns>
        public static T GetOrCreateExtensionState <T>(this MetricManager metricManager, Func <MetricManager, T> newExtensionStateInstanceFactory)
            where T : class
        {
            Util.ValidateNotNull(metricManager, nameof(metricManager));

            object cache = metricManager.GetOrCreateExtensionStateUnsafe(newExtensionStateInstanceFactory);

            if (cache == null)
            {
                return(null);
            }

            T typedCache = cache as T;

            if (typedCache == null)
            {
                throw new InvalidOperationException($"{nameof(MetricManagerExtensions)}.{nameof(GetOrCreateExtensionState)}<T>(..) expected to find a"
                                                    + $" cache of type {typeof(T).FullName}, but the present cache was of"
                                                    + $" type {cache.GetType().FullName}. This indicates that multiple extensions attempt to use"
                                                    + $" this extension point of the {nameof(MetricManager)} in a conflicting manner.");
            }

            return(typedCache);
        }
Пример #26
0
        private static Metric GetOrCreateMetric(
            TelemetryClient telemetryClient,
            MetricAggregationScope aggregationScope,
            string metricId,
            string dimension1Name,
            string dimension2Name,
            IMetricConfiguration metricConfiguration)
        {
            Util.ValidateNotNull(telemetryClient, nameof(telemetryClient));

            MetricManager metricManager = telemetryClient.GetMetricManager(aggregationScope);
            MetricsCache  cache         = metricManager.GetOrCreateExtensionState(MetricsCache.CreateNewInstance);

            if (cache == null)
            {
                throw new InvalidOperationException($"telemetryConfiguration.GetMetricManager().GetOrCreateExtensionState(..) unexpectedly returned null."
                                                    + $" This indicates that multiple extensions attempt to use"
                                                    + $" the \"Cache\" extension point of the {nameof(MetricManager)} in a conflicting manner.");
            }

            Metric metric = cache.GetOrCreateMetric(metricId, dimension1Name, dimension2Name, metricConfiguration);

            return(metric);
        }
Пример #27
0
 void Start()
 {
     player     = transform.GetComponent <Player>();
     jump_timer = 0;
     mm         = GameObject.Find("EventSystem").GetComponent <MetricManager>();
 }
Пример #28
0
        internal static bool TryGetMetricManager(this TelemetryClient telemetryClient, out MetricManager metricManager)
        {
            if (telemetryClient == null)
            {
                metricManager = null;
                return(false);
            }

            ConditionalWeakTable <TelemetryClient, MetricManager> metricManagers = metricManagersForTelemetryClients;

            if (metricManagers == null)
            {
                metricManager = null;
                return(false);
            }

            return(metricManagers.TryGetValue(telemetryClient, out metricManager));
        }
        public void SetMetricManager( MetricManager mmMetricManager )
        {
            // get the variable (attribute) by name
            FieldInfo fiTest	=
                _objInstantiatedEvaluator.GetType().GetField( "mmMetricManager" );

            if( fiTest == null )
                throw new Exception( "Could not find attribute mmMetricManager" +
                    " in " + strLoadedDLLName );

            // change the value of the variable
            fiTest.SetValue( _objInstantiatedEvaluator, (object) mmMetricManager );
        }
 public DependencyFilteringWithMetricsTelemetryProcessor(ITelemetryProcessor next, TelemetryConfiguration configuration)
 {
     this.next    = next;
     this.manager = new MetricManager(new TelemetryClient(configuration));
 }
Пример #31
0
        static void Main_backup(string[] args)
        {
            var state = new _State();

            state.Initialize();

            TelemetryConfiguration configuration = new TelemetryConfiguration();

            configuration.InstrumentationKey = "fb8a0b03-235a-4b52-b491-307e9fd6b209";

            var telemetryChannel = new ServerTelemetryChannel();

            telemetryChannel.Initialize(configuration);
            configuration.TelemetryChannel = telemetryChannel;


            // data collection modules
            var dependencies = new DependencyTrackingTelemetryModule();

            dependencies.Initialize(configuration);

            // telemetry initializers
            configuration.TelemetryInitializers.Add(new AppVersionTelemetryInitializer());
            configuration.TelemetryInitializers.Add(new DefaultTelemetryInitializer());
            configuration.TelemetryInitializers.Add(new BusinessTelemetryInitializer());
            configuration.TelemetryInitializers.Add(new NodeNameTelemetryInitializer());
            configuration.TelemetryInitializers.Add(new OperationCorrelationTelemetryInitializer());

            // telemetry processors
            configuration.TelemetryProcessorChainBuilder
            .Use((next) => { return(new PriceCalculatorTelemetryProcessor(next, state.Collected)); })
//                .Use((next) => { return new MyTelemetryProcessor(next); })
//                .Use((next) => { return new CleanAutoCollecctedTelemetryProcessor(next); })
//                .Use((next) => { return new ExampleTelemetryProcessor(next); })
            // send only 10% of all dependency data
            .Use((next) =>
            {
                return(new SamplingTelemetryProcessor(next)
                {
                    IncludedTypes = "Dependency",
                    SamplingPercentage = 10
                });
            })
            // start sampling when load exceeds 2 events per second for all telemetry types except events
            .Use((next) =>
            {
                return(new AdaptiveSamplingTelemetryProcessor(next)
                {
                    ExcludedTypes = "Event",
                    MaxTelemetryItemsPerSecond = 2,
                    SamplingPercentageIncreaseTimeout = TimeSpan.FromSeconds(1),
                    SamplingPercentageDecreaseTimeout = TimeSpan.FromSeconds(1),
                    EvaluationInterval = TimeSpan.FromSeconds(1),
                    InitialSamplingPercentage = 25
                });
            })
            .Use((next) => { return(new PriceCalculatorTelemetryProcessor(next, state.Sent)); })
            .Build();

            TelemetryClient client = new TelemetryClient(configuration);

            var iterations = 0;


            MetricManager metricManager    = new MetricManager(client);
            var           itemsProcessed   = metricManager.CreateMetric("Items processed");
            var           processingFailed = metricManager.CreateMetric("Failed processing");
            var           processingSize   = metricManager.CreateMetric("Processing size");


            while (!state.IsTerminated)
            {
                iterations++;

                using (var operaiton = client.StartOperation <RequestTelemetry>("Process item"))
                {
                    client.TrackEvent("test");
                    client.TrackTrace("Something happened");

                    try
                    {
                        HttpClient http = new HttpClient();
                        var        task = http.GetStringAsync("http://bing.com");
                        task.Wait();

                        // metrics aggregation:
                        //itemsProcessed.Track(1);
                        //processingSize.Track(task.Result.Length);
                        //processingFailed.Track(0);

                        //client.TrackMetric("Response size", task.Result.Length);
                        //client.TrackMetric("Successful responses", 1);
                    }
                    catch (Exception exc)
                    {
                        //client.TrackMetric("Successful responses", 0);
                        //operaiton.Telemetry.Success = false;

                        // metrics aggregation:
                        //processingFailed.Track(1);
                    }
                }
            }

            Console.WriteLine($"Program sent 1Mb of telemetry in {iterations} iterations!");
            Console.ReadLine();
        }
        /// <summary>
        /// Initializes the telemetry module.
        /// </summary>
        /// <param name="configuration">Telemetry Configuration used for creating TelemetryClient for sending exception statistics to Application Insights.</param>
        public void Initialize(TelemetryConfiguration configuration)
        {
            // Core SDK creates 1 instance of a module but calls Initialize multiple times
            if (!this.isInitialized)
            {
                lock (this.lockObject)
                {
                    if (!this.isInitialized)
                    {
                        this.isInitialized = true;

                        this.telemetryClient = new TelemetryClient(configuration);
                        this.telemetryClient.Context.GetInternalContext().SdkVersion = SdkVersionUtils.GetSdkVersion("exstat:");

                        this.metricManager = new MetricManager(this.telemetryClient);

                        this.registerAction(this.CalculateStatistics);
                    }
                }
            }
        }