public TelemetrySender(Stream stream, TelemetryConfig config, Layout layout) { _stream = stream; _config = config; _messages = new List <TelemetryMessage>(); layout.Bind("telemetry", this); }
/// <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); }
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); }
/// <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)); }
private static void Startup(ExecutionParameters parameters) { LogConfig.Config(); TelemetryConfig.Config(); ExceptionHandling.Config(); IoCConfig.Config(); ConfigureDapper.Config(); GlobalizationConfig.Config(parameters.Get("culture")); }
/// <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); }
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); }
private static void ConfigureRollbarServer() { TelemetryConfig telemetryConfig = new TelemetryConfig( telemetryEnabled: true, telemetryQueueDepth: 3 ); Server server = new Server(); server.CodeVersion = "2"; RollbarLocator.RollbarInstance.Config.Server = server; }
/// <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); }
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); }
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)); }
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."); }
/// <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); }
/// <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); }
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) }; }
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); }
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()); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
/// <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())); }
/// <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)); }
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)); }