Exemplo n.º 1
0
 public TelemetrySender(Stream stream, TelemetryConfig config, Layout layout)
 {
     _stream   = stream;
     _config   = config;
     _messages = new List <TelemetryMessage>();
     layout.Bind("telemetry", this);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="telemetryConfig">The configuration.</param>
        /// <param name="telemetryConfigSection">The application settings.</param>
        /// <returns>false when the configuration was not found, otherwise true.</returns>
        public static bool LoadAppSettings(TelemetryConfig telemetryConfig, RollbarTelemetryConfigSection telemetryConfigSection)
        {
            if (telemetryConfigSection == null)
            {
                return(false);
            }

            if (telemetryConfigSection.TelemetryEnabled.HasValue)
            {
                telemetryConfig.TelemetryEnabled = telemetryConfigSection.TelemetryEnabled.Value;
            }
            if (telemetryConfigSection.TelemetryQueueDepth.HasValue)
            {
                telemetryConfig.TelemetryQueueDepth = telemetryConfigSection.TelemetryQueueDepth.Value;
            }
            if (telemetryConfigSection.TelemetryAutoCollectionTypes.HasValue)
            {
                telemetryConfig.TelemetryAutoCollectionTypes = telemetryConfigSection.TelemetryAutoCollectionTypes.Value;
            }
            if (telemetryConfigSection.TelemetryAutoCollectionInterval.HasValue)
            {
                telemetryConfig.TelemetryAutoCollectionInterval = telemetryConfigSection.TelemetryAutoCollectionInterval.Value;
            }

            return(true);
        }
Exemplo n.º 3
0
        private CdmCorpusDefinition InitializeClientWithDefaultDatabase()
        {
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, "TestTelemetryKustoClient");

            string tenantId     = Environment.GetEnvironmentVariable("KUSTO_TENANTID");
            string clientId     = Environment.GetEnvironmentVariable("KUSTO_CLIENTID");
            string secret       = Environment.GetEnvironmentVariable("KUSTO_SECRET");
            string clusterName  = Environment.GetEnvironmentVariable("KUSTO_CLUSTER");
            string databaseName = Environment.GetEnvironmentVariable("KUSTO_DATABASE");

            Assert.IsFalse(string.IsNullOrEmpty(tenantId), "KUSTO_TENANTID not set");
            Assert.IsFalse(string.IsNullOrEmpty(clientId), "KUSTO_CLIENTID not set");
            Assert.IsFalse(string.IsNullOrEmpty(secret), "KUSTO_SECRET not set");
            Assert.IsFalse(string.IsNullOrEmpty(clusterName), "KUSTO_CLUSTER not set");
            Assert.IsFalse(string.IsNullOrEmpty(databaseName), "KUSTO_DATABASE not set");

            TelemetryConfig kustoConfig = new TelemetryConfig(tenantId, clientId, secret, clusterName, databaseName, EnvironmentType.DEV, removeUserContent: false);

            corpus.TelemetryClient = new TelemetryKustoClient(corpus.Ctx, kustoConfig);
            corpus.AppId           = "CDM Integration Test";

            // set callback to receive error and warning logs.
            corpus.SetEventCallback(new EventCallback
            {
                Invoke = (level, message) =>
                {
                    // Do nothing
                }
            }, CdmStatusLevel.Progress);

            return(corpus);
        }
        public void LoadRollbarTelemetryAppSettingsTest()
        {
            TelemetryConfig config = new TelemetryConfig(false, 5, TelemetryType.None, TimeSpan.FromMilliseconds(100));

            Console.WriteLine(JsonConvert.SerializeObject(config));

            Assert.AreEqual(false, config.TelemetryEnabled);
            Assert.AreEqual(5, config.TelemetryQueueDepth);
            Assert.AreEqual(TelemetryType.None, config.TelemetryAutoCollectionTypes);
            Assert.AreEqual(TimeSpan.FromMilliseconds(100), config.TelemetryAutoCollectionInterval);

            AppSettingsUtil.LoadAppSettings(ref config, Path.Combine(Environment.CurrentDirectory, "TestData"), "appsettings.json");
            Console.WriteLine(JsonConvert.SerializeObject(config));

            // The test data looks like this:
            //===============================
            //"RollbarTelemetry": {
            //    "TelemetryEnabled": true,
            //    "TelemetryQueueDepth": 100,
            //    "TelemetryAutoCollectionTypes": "Network, Log, Error",
            //    "TelemetryAutoCollectionInterval":  "00:00:00.3000000",
            //},

            Assert.AreEqual(true, config.TelemetryEnabled);
            Assert.AreEqual(100, config.TelemetryQueueDepth);
            Assert.AreEqual(TelemetryType.Network | TelemetryType.Log | TelemetryType.Error, config.TelemetryAutoCollectionTypes);
            Assert.AreEqual(TimeSpan.FromMilliseconds(300), config.TelemetryAutoCollectionInterval);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="appSettings">The application settings.</param>
        /// <returns>false when the configuration was not found, otherwise true.</returns>
        public static bool LoadAppSettings(TelemetryConfig config, IConfiguration appSettings)
        {
            Assumption.AssertNotNull(config, nameof(config));

            const string rollbarAppConfigSectionName = "RollbarTelemetry";

            return(AppSettingsUtility.LoadAppSettings(config, rollbarAppConfigSectionName, appSettings));
        }
Exemplo n.º 6
0
 private static void Startup(ExecutionParameters parameters)
 {
     LogConfig.Config();
     TelemetryConfig.Config();
     ExceptionHandling.Config();
     IoCConfig.Config();
     ConfigureDapper.Config();
     GlobalizationConfig.Config(parameters.Get("culture"));
 }
Exemplo n.º 7
0
        /// <summary>
        /// Configures the Rollbar telemetry.
        /// </summary>
        private static void ConfigureRollbarTelemetry()
        {
            TelemetryConfig telemetryConfig = new TelemetryConfig(
                telemetryEnabled: true,
                telemetryQueueDepth: 3
                );

            TelemetryCollector.Instance.Config.Reconfigure(telemetryConfig);
        }
        /// <summary>
        /// Loads the telemetry configuration.
        /// </summary>
        /// <returns>ITelemetryConfig.</returns>
        /// <returns>Either IRollbarConfig or null if no configuration file found.</returns>
        public static ITelemetryConfig LoadTelemetryConfig()
        {
            TelemetryConfig config = new TelemetryConfig();

            if (RollbarConfigUtility.Load(config))
            {
                return(config);
            }
            return(null);
        }
Exemplo n.º 9
0
 public CurrentDeviceValues(TelemetryConfig config)
 {
     //Add devices
     foreach (var item in config)
     {
         this.Add(new DeviceValue {
             Hash = item.Name.GetHash64(), Device = item.Name, TypeCode = item.TypeCode
         });
     }
 }
        /// <summary>
        /// Deduces the rollbar telemetry configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        public static ITelemetryConfig DeduceRollbarTelemetryConfig(IConfiguration configuration)
        {
            TelemetryConfig config = new TelemetryConfig();

            AppSettingsUtility.LoadAppSettings(config, configuration);

            TelemetryCollector.Instance.Config.Reconfigure(config);

            return(config);
        }
        /// <summary>
        /// Loads the telemetry configuration.
        /// </summary>
        /// <returns>ITelemetryConfig or null if no configuration store was found.</returns>
        public ITelemetryConfig LoadTelemetryConfig()
        {
            TelemetryConfig config = new TelemetryConfig();

            if (this.Load(config))
            {
                return(config);
            }
            return(null);
        }
Exemplo n.º 12
0
        private static void ConfigureRollbarServer()
        {
            TelemetryConfig telemetryConfig = new TelemetryConfig(
                telemetryEnabled: true,
                telemetryQueueDepth: 3
                );
            Server server = new Server();

            server.CodeVersion = "2";
            RollbarLocator.RollbarInstance.Config.Server = server;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="appSettingsFolderPath">The application settings folder path.</param>
        /// <param name="appSettingsFileName">Name of the application settings file.</param>
        /// <returns>false when the configuration was not found, otherwise true.</returns>
        public static bool LoadAppSettings(TelemetryConfig config, string appSettingsFolderPath, string appSettingsFileName)
        {
            Assumption.AssertNotNull(config, nameof(config));

            IConfiguration appSettingsConfig = AppSettingsUtility.LoadAppSettings(appSettingsFolderPath, appSettingsFileName);

            if (appSettingsConfig == null)
            {
                return(false);
            }

            AppSettingsUtility.LoadAppSettings(config, appSettingsConfig);
            return(true);
        }
Exemplo n.º 14
0
        public void MatsCanBeProperlyConfigured()
        {
            var telemetryConfig = new TelemetryConfig
            {
                SessionId = "some session id"
            };

            var app = PublicClientApplicationBuilder.Create(TestConstants.ClientId)
                      .WithTelemetry(telemetryConfig)
                      .Build();

            Assert.IsNotNull(app.AppConfig.TelemetryConfig);
            Assert.AreEqual <string>(telemetryConfig.SessionId, app.AppConfig.TelemetryConfig.SessionId);
        }
Exemplo n.º 15
0
        public MainPageViewModel()
        {
            _stream = new StreamSocket();
            TelemetryConfig config = TelemetryConfig.Meadow;

            _telemetryDeviceToHash = config.ToDictionary(i => i.Name, i => i.Name.GetHash64());
            _telemetryHashToDevice = config.ToDictionary(i => i.Name.GetHash64(), i => i.Name);
            _telemetryHashToType   = config.ToDictionary(i => i.Name.GetHash64(), i => i.TypeCode);

            _telemetry    = new Dictionary <Int64, ObservableCollection <Data> >();
            CurrentValues = new CurrentDeviceValues(config);

            SendCommand = new RelayCommand((state) => Send(state));
        }
Exemplo n.º 16
0
        public void TestAadAppAuthorizationException()
        {
            // initialize with some dummy credentials
            var             corpus      = new CdmCorpusDefinition();
            TelemetryConfig kustoConfig = new TelemetryConfig("tenant id", "client id", "secret", "cluster name", "database name", EnvironmentType.DEV, removeUserContent: false);

            corpus.TelemetryClient = new TelemetryKustoClient(corpus.Ctx, kustoConfig);

            Func <Task> func = async() =>
            {
                await(corpus.TelemetryClient as TelemetryKustoClient).PostKustoQuery("some random query");
            };

            func.Should().Throw <System.Exception>("Kusto cluster authentication failed.");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Loads the telemetry configuration.
        /// </summary>
        /// <param name="configFileName">Name of the configuration file.</param>
        /// <param name="configFilePath">The configuration file path.</param>
        /// <returns>Either IRollbarConfig or null if no configuration file found.</returns>
        public static ITelemetryConfig LoadTelemetryConfig(string configFileName, string configFilePath = null)
        {
            TelemetryConfig config = new TelemetryConfig();

            if (string.IsNullOrWhiteSpace(configFilePath))
            {
                if (!NetCore.AppSettingsUtility.LoadAppSettings(config, configFileName))
                {
                    return(null);
                }
            }
            else if (!NetCore.AppSettingsUtility.LoadAppSettings(config, configFilePath, configFileName))
            {
                return(null);
            }

            return(config);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Loads the specified configuration.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <returns><c>true</c> if configuration was found, <c>false</c> otherwise.</returns>
        public static bool Load(TelemetryConfig config)
        {
            // try app.config file:
            if (NetFramework.AppConfigUtility.LoadAppSettings(config))
            {
                return(true);
            }

#if NETCOREAPP || NETSTANDARD
            // try appsettings.json file:
            if (NetCore.AppSettingsUtility.LoadAppSettings(config))
            {
                return(true);
            }
#endif

            return(false);
        }
Exemplo n.º 19
0
        public EnvironmentSensingDeviceClient(EG.IoT.Utils.IoTHubConnector connector, BarometerBME280 sensor, GrovePiPlusBlueLEDButton ledButton, GrovePiLightSensor lightSensor, CO2SensorMHZ19B co2Sensor)
        {
            iothubClient      = connector;
            envSensorDevice   = sensor;
            ledButtonDevice   = ledButton;
            lightSensorDevice = lightSensor;
            co2SensorDevice   = co2Sensor;

            telemetryConfig = new TelemetryConfig()
            {
                telemetryCycleMSec   = 1000,
                temperatureAvailable = true,
                humidityAvailable    = true,
                pressureAvailable    = true,
                lightSenseAvailable  = (lightSensor != null),
                co2SensorAvailable   = (co2Sensor != null)
            };
        }
Exemplo n.º 20
0
        private CdmCorpusDefinition InitializeClientWithUserDatabase()
        {
            CdmCorpusDefinition corpus = TestHelper.GetLocalCorpus(testsSubpath, "TestTelemetryKustoClient");

            // TODO: need to investigate why only Java not failing if using event callback from GetLocalCorpus()
            // set callback to receive error and warning logs.
            corpus.SetEventCallback(new EventCallback
            {
                Invoke = (level, message) =>
                {
                    // Do nothing
                }
            }, CdmStatusLevel.Progress);


            string tenantId = Environment.GetEnvironmentVariable("KUSTO_TENANTID");
            string clientId = Environment.GetEnvironmentVariable("KUSTO_CLIENTID");
            string secret   = Environment.GetEnvironmentVariable("KUSTO_SECRET");

            string clusterName  = Environment.GetEnvironmentVariable("KUSTO_CLUSTER");
            string databaseName = Environment.GetEnvironmentVariable("KUSTO_DATABASE");
            string infoTable    = Environment.GetEnvironmentVariable("KUSTO_INFOTABLE");
            string warningTable = Environment.GetEnvironmentVariable("KUSTO_WARNINGTABLE");
            string errorTable   = Environment.GetEnvironmentVariable("KUSTO_ERRORTABLE");

            Assert.IsFalse(string.IsNullOrEmpty(tenantId), "KUSTO_TENANTID not set");
            Assert.IsFalse(string.IsNullOrEmpty(clientId), "KUSTO_CLIENTID not set");
            Assert.IsFalse(string.IsNullOrEmpty(secret), "KUSTO_SECRET not set");

            Assert.IsFalse(string.IsNullOrEmpty(clusterName), "KUSTO_CLUSTER not set");
            Assert.IsFalse(string.IsNullOrEmpty(databaseName), "KUSTO_DATABASE not set");
            Assert.IsFalse(string.IsNullOrEmpty(infoTable), "KUSTO_INFOTABLE not set");
            Assert.IsFalse(string.IsNullOrEmpty(warningTable), "KUSTO_WARNINGTABLE not set");
            Assert.IsFalse(string.IsNullOrEmpty(errorTable), "KUSTO_ERRORTABLE not set");

            TelemetryConfig kustoConfig = new TelemetryConfig(tenantId, clientId, secret,
                                                              clusterName, databaseName, infoTable, warningTable, errorTable, EnvironmentType.DEV, removeUserContent: false);

            corpus.TelemetryClient = new TelemetryKustoClient(corpus.Ctx, kustoConfig);

            corpus.AppId = "CDM Integration Test";

            return(corpus);
        }
Exemplo n.º 21
0
        public void TestTelemetryFixedQueueDepth()
        {
            TelemetryCollector.Instance.FlushQueue();
            Assert.IsFalse(TelemetryCollector.Instance.IsAutocollecting);

            var config  = TelemetryCollector.Instance.Config;
            var config1 = new TelemetryConfig(true, 10);

            config.Reconfigure(config1);

            List <dto.Telemetry> telemetryItems = new List <dto.Telemetry>(2 * config.TelemetryQueueDepth);

            while (telemetryItems.Count <= config.TelemetryQueueDepth)
            {
                telemetryItems.AddRange(GenerateTelemetryItems());
            }

            Assert.IsTrue(config.TelemetryEnabled);
            Assert.AreEqual(0, TelemetryCollector.Instance.GetItemsCount());
            Assert.IsTrue(telemetryItems.Count > config.TelemetryQueueDepth);
            foreach (var item in telemetryItems)
            {
                TelemetryCollector.Instance.Capture(item);
            }
            Assert.AreEqual(config.TelemetryQueueDepth, TelemetryCollector.Instance.GetItemsCount());
            int oldCount = TelemetryCollector.Instance.GetItemsCount();

            TelemetryCollector.Instance.FlushQueue();
            Assert.AreEqual(0, TelemetryCollector.Instance.GetItemsCount());
            var config2 = new TelemetryConfig(true, config1.TelemetryQueueDepth / 2);

            config.Reconfigure(config2);
            foreach (var item in telemetryItems)
            {
                TelemetryCollector.Instance.Capture(item);
            }
            Assert.AreEqual(config.TelemetryQueueDepth, TelemetryCollector.Instance.GetItemsCount());
            Assert.IsTrue(oldCount > TelemetryCollector.Instance.GetItemsCount());
        }
Exemplo n.º 22
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="appSettingsFolderPath">The application settings folder path.</param>
        /// <param name="appSettingsFileName">Name of the application settings file.</param>
        public static void LoadAppSettings(ref TelemetryConfig config, string appSettingsFolderPath, string appSettingsFileName)
        {
            IConfiguration appSettingsConfig = AppSettingsUtil.LoadAppSettings(appSettingsFolderPath, appSettingsFileName);

            AppSettingsUtil.LoadAppSettings(ref config, appSettingsConfig);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="config">The configuration.</param>
        public static void LoadAppSettings(ref TelemetryConfig config)
        {
            IConfiguration appSettingsConfig = AppSettingsUtil.LoadAppSettings();

            AppSettingsUtil.LoadAppSettings(ref config, appSettingsConfig);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="appSettings">The application settings.</param>
        public static void LoadAppSettings(ref TelemetryConfig config, IConfiguration appSettings)
        {
            const string rollbarAppConfigSectionName = "RollbarTelemetry";

            AppSettingsUtil.LoadAppSettings(ref config, rollbarAppConfigSectionName, appSettings);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Loads the provided configuration object based on found configuration store (if any).
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <returns><c>true</c> if configuration was found, <c>false</c> otherwise.</returns>
 public bool Load(TelemetryConfig config)
 {
     return(this._loader != null && this._loader.Load(config));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Loads the application settings.
 /// </summary>
 /// <param name="telemetryConfig">The configuration.</param>
 /// <returns>false when the configuration was not found, otherwise true.</returns>
 public static bool LoadAppSettings(TelemetryConfig telemetryConfig)
 {
     return(AppConfigUtility.LoadAppSettings(telemetryConfig, RollbarTelemetryConfigSection.GetConfiguration()));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Loads the specified configuration.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <returns><c>true</c> if configuration was found, <c>false</c> otherwise.</returns>
 public static bool Load(TelemetryConfig config)
 {
     return(RollbarConfigUtility.configurationLoader.Load(config));
 }
Exemplo n.º 28
0
 public TagGroup(string name)
 {
     this._name = name;
     _tags      = new ConcurrentDictionary <string, Tag>();
     _config    = new TelemetryConfig();
 }
 /// <summary>
 /// Loads the provided configuration object based on found configuration store (if any).
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <returns><c>true</c> if configuration was found, <c>false</c> otherwise.</returns>
 public bool Load(TelemetryConfig config)
 {
     return(AppSettingsUtility.LoadAppSettings(config));
 }