internal RawCounterGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable, ICachedEnvironmentVariableAccess cache) { this.name = name; this.jsonId = jsonId; this.environmentVariable = environmentVariable; this.cacheHelper = cache; }
internal RawCounterGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable, ICachedEnvironmentVariableAccess cache) { this.name = name; this.jsonId = jsonId; this.environmentVariable = environmentVariable; this.cacheHelper = cache; }
/// <summary> /// Retrieves raw counter data from Environment Variables. /// </summary> /// <param name="name"> Name of the counter to be selected from JSON.</param> /// <param name="environmentVariable">Environment variables - unused.</param> /// <returns> Value of the counter.</returns> public long GetCounterValue(string name, AzureWebApEnvironmentVariables environmentVariable) { if (this.returnJsonOne) { this.returnJsonOne = false; return(CacheHelper.PerformanceCounterValue(name, this.jsonOne)); } else { this.returnJsonOne = true; return(CacheHelper.PerformanceCounterValue(name, this.jsonTwo)); } }
/// <summary> /// Retrieves raw counter data from Environment Variables. /// </summary> /// <param name="name"> Name of the counter to be selected from JSON.</param> /// <returns> Value of the counter.</returns> public long GetCounterValue(string name, AzureWebApEnvironmentVariables environmentVariable) { if (this.returnJsonOne) { this.returnJsonOne = false; return CacheHelper.Instance.PerformanceCounterValue(name, this.jsonOne); } else { this.returnJsonOne = true; return CacheHelper.Instance.PerformanceCounterValue(name, this.jsonTwo); } }
/// <summary> /// Retrieves raw counter data from Environment Variables. /// </summary> /// <param name="name"> Name of the counter to be selected from JSON.</param> /// <returns> Value of the counter.</returns> public int GetCounterValue(string name, AzureWebApEnvironmentVariables environmentVariable) { if (returnJsonOne) { returnJsonOne = false; return(CacheHelper.Instance.PerformanceCounterValue(name, jsonOne)); } else { returnJsonOne = true; return(CacheHelper.Instance.PerformanceCounterValue(name, jsonTwo)); } }
/// <summary> /// Checks if a key is in the cache and if not /// Retrieves raw counter data from Environment Variables /// Cleans raw JSON for only requested counter /// Creates value for caching. /// </summary> /// <param name="name">Cache key and name of the counter to be selected from JSON.</param> /// <param name="environmentVariable">Identifier of the environment variable.</param> /// <returns>Value from cache.</returns> public long GetCounterValue(string name, AzureWebApEnvironmentVariables environmentVariable) { if (!CacheHelper.Instance.IsInCache(name)) { PerformanceCounterImplementation client = new PerformanceCounterImplementation(); string uncachedJson = client.GetAzureWebAppEnvironmentVariables(environmentVariable); if (uncachedJson == null) { return(0); } CacheHelper.Instance.SaveToCache(name, uncachedJson, DateTimeOffset.Now.AddMilliseconds(500)); } string json = this.GetFromCache(name).ToString(); long value = PerformanceCounterValue(name, json); return(value); }
/// <summary> /// Checks if a key is in the cache and if not /// Retrieves raw counter data from Environment Variables /// Cleans raw JSON for only requested counter /// Creates value for caching. /// </summary> /// <param name="name">Cache key and name of the counter to be selected from JSON.</param> /// <param name="environmentVariable">Identifier of the environment variable.</param> /// <returns>Value from cache.</returns> public long GetCounterValue(string name, AzureWebApEnvironmentVariables environmentVariable) { if (!CacheHelper.Instance.IsInCache(name)) { PerformanceCounterImplementation client = new PerformanceCounterImplementation(); string uncachedJson = client.GetAzureWebAppEnvironmentVariables(environmentVariable); if (uncachedJson == null) { return 0; } CacheHelper.Instance.SaveToCache(name, uncachedJson, DateTimeOffset.Now.AddMilliseconds(500)); } string json = this.GetFromCache(name).ToString(); long value = this.PerformanceCounterValue(name, json); return value; }
/// <summary> /// Retrieves counter data from Azure Web App Environment Variables. /// </summary> /// <param name="environmentVariable">Name of environment variable.</param> /// <returns>Raw JSON with counters.</returns> public string GetAzureWebAppEnvironmentVariables(AzureWebApEnvironmentVariables environmentVariable) { return Environment.GetEnvironmentVariable(this.environmentVariableMapping[environmentVariable]); }
/// <summary> /// Initializes a new instance of the <see cref="RateCounterGauge"/> class. /// </summary> /// <param name="name"> Name of counter variable.</param> /// <param name="jsonId">JSON identifier of the counter variable.</param> /// <param name="environmentVariable"> Identifier of the corresponding environment variable.</param> /// <param name="counter">Dependant counter.</param> public RateCounterGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable, ICounterValue counter = null) : this(name, jsonId, environmentVariable, counter, CacheHelper.Instance) { }
/// <summary> /// Retrieves counter data from Azure Web App Environment Variables. /// </summary> /// <param name="environmentVariable">Name of environment variable</param> /// <returns>Raw Json with</returns> public string GetAzureWebAppEnvironmentVariables(AzureWebApEnvironmentVariables environmentVariable) { return(Environment.GetEnvironmentVariable(this.listEnvironmentVariables[(int)environmentVariable])); }
/// <summary> /// Initializes a new instance of the <see cref="RateCounterGauge"/> class. /// </summary> /// <param name="name"> Name of counter variable.</param> /// <param name="jsonId">JSON identifier of the counter variable.</param> /// <param name="environmentVariable"> Identifier of the corresponding environment variable.</param> /// <param name="counter">Dependant counter.</param> public RateCounterGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable, ICounterValue counter = null) : this(name, jsonId, environmentVariable, counter, CacheHelper.Instance) { }
/// <summary> /// Initializes a new instance of the <see cref="RawCounterGauge"/> class. /// </summary> /// <param name="name">Name of counter variable.</param> /// <param name="jsonId">JSON identifier of the counter variable.</param> /// <param name="environmentVariable">Identifier of the environment variable.</param> public RawCounterGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable) : this(name, jsonId, environmentVariable, CacheHelper.Instance) { }
/// <summary> /// Initializes a new instance of the <see cref="PerformanceCounterFromJsonGauge"/> class. /// </summary> /// <param name="name">Name of counter variable.</param> /// <param name="jsonId">Json identifier of the counter variable.</param> /// <param name="environmentVariable">Identifier of the environment variable.</param> public PerformanceCounterFromJsonGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable) : this(name, jsonId, environmentVariable, CacheHelper.Instance) { }
/// <summary> /// Initializes a new instance of the <see cref="RawCounterGauge"/> class. /// </summary> /// <param name="name">Name of counter variable.</param> /// <param name="jsonId">JSON identifier of the counter variable.</param> /// <param name="environmentVariable">Identifier of the environment variable.</param> public RawCounterGauge(string name, string jsonId, AzureWebApEnvironmentVariables environmentVariable) : this(name, jsonId, environmentVariable, CacheHelper.Instance) { }
/// <summary> /// Retrieves counter data from Azure Web App Environment Variables. /// </summary> /// <param name="environmentVariable">Name of environment variable.</param> /// <returns>Raw JSON with counters.</returns> public string GetAzureWebAppEnvironmentVariables(AzureWebApEnvironmentVariables environmentVariable) { return(Environment.GetEnvironmentVariable(this.environmentVariableMapping[environmentVariable])); }