Esempio n. 1
0
        public void AppInsightSimpleMessageTest()
        {
            #region arrange
            IDiagnostic trace   = new ApplicationInsightsTrace();
            string      message = "ciao";
            #endregion

            #region act
            trace.trace(message);
            #endregion

            #region assert
            Assert.IsTrue(true);
            #endregion

            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine(i);
                System.Threading.Thread.Sleep(500);
            }
            // ADD LOOP PAUSE ETC TO LET THE TRACKING BE COMPLETE
        }
Esempio n. 2
0
        public static void mainApplicationInsights()
        {
            //_ = TelemetryConfiguration.Active;
            //TelemetryConfiguration configuration = TelemetryConfiguration.Active;
            //TelemetryClient telemetryClient = new TelemetryClient(configuration);
            //telemetryClient.TrackTrace("Good evening with wait");
            //telemetryClient.Flush(); // force empty of the buffer: the SDK send data each 30 sec. or when the buffer is full

            ApplicationInsightsTrace trace = new ApplicationInsightsTrace();

            trace.trace("try again....");

            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine(i);
                trace.trace("try again...." + i);
                System.Threading.Thread.Sleep(500);
            }

            System.Threading.Thread.Sleep(10000);
            Console.WriteLine("END");
        }
Esempio n. 3
0
        public void AppInsightsJsonMessageTest()
        {
            /*
             *
             * ApplicationInsights query for custom dimensions:
             * traces
             * | where customDimensions.['MyPro1']=="prop1_value"
             *
             */
            #region arrange
            JObject _jobject = new JObject();
            string  header   = "This is my header message";
            _jobject.Add(new JProperty("header", header));
            _jobject.Add(new JProperty("MyProp1", "prop1_value"));
            _jobject.Add(new JProperty("MyProp2", "prop2_value"));
            _jobject.Add(new JProperty("MyProp3", "prop3_value"));
            _jobject.Add(new JProperty("requestTime", DateTime.Now.ToString("yyyyMMdd HH:mm:ss")));
            string message = _jobject.ToString(Formatting.None);
            ApplicationInsightsTrace trace = new ApplicationInsightsTrace();
            #endregion

            #region act
            trace.trace(message);
            #endregion

            #region assert
            Assert.IsTrue(true);
            #endregion

            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine(i);
                System.Threading.Thread.Sleep(500);
            }
            // ADD LOOP PAUSE ETC TO LET THE TRACKING BE COMPLETE
        }