/// <summary> /// Constructs a <c>MetricsProperties</c> object from an XML element. /// </summary> /// <param name="element">The XML element.</param> /// <returns>A <c>MetricsProperties</c> object containing the properties in the element.</returns> internal static MetricsProperties ReadMetricsPropertiesFromXml(XElement element) { if (element == null) { return(null); } MetricsLevel state = MetricsLevel.None; if (bool.Parse(element.Element(EnabledName).Value)) { state = MetricsLevel.Service; if (bool.Parse(element.Element(IncludeApisName).Value)) { state = MetricsLevel.ServiceAndApi; } } return(new MetricsProperties { Version = element.Element(VersionName).Value, MetricsLevel = state, RetentionDays = ReadRetentionPolicyFromXml(element.Element(RetentionPolicyName)) }); }
internal void ExpectValidmetricsOperation(Constants.ServiceType serviceType, string operations, GetMetricsProperty <ServiceProperties> getServiceProperties) { int retentionDays = Utility.GetRandomTestCount(1, 365 + 1); Test.Assert(CommandAgent.SetAzureStorageServiceMetrics(serviceType, Constants.MetricsType.Hour, operations, retentionDays.ToString(), string.Empty), "Set hour metrics level should succeed"); ServiceProperties retrievedProperties = getServiceProperties(Constants.MetricsType.Hour, retentionDays, operations); MetricsLevel expectOperation = (MetricsLevel)Enum.Parse(typeof(MetricsLevel), operations, true); ExpectEqual(expectOperation.ToString(), retrievedProperties.HourMetrics.MetricsLevel.ToString(), "hour metrics level"); Test.Assert(CommandAgent.SetAzureStorageServiceMetrics(serviceType, Constants.MetricsType.Minute, operations, retentionDays.ToString(), string.Empty), "Set minute metrics level should succeed"); retrievedProperties = getServiceProperties(Constants.MetricsType.Minute, retentionDays, operations); expectOperation = (MetricsLevel)Enum.Parse(typeof(MetricsLevel), operations, true); ExpectEqual(expectOperation.ToString(), retrievedProperties.MinuteMetrics.MetricsLevel.ToString(), "minute metrics level"); }
public static MetricsProperties ConvertMetricsProperties(TableMetrics tableMetrics) { MetricsLevel metricsLevel = MetricsLevel.None; if (tableMetrics.Enabled) { if (tableMetrics.IncludeApis.HasValue && tableMetrics.IncludeApis.Value) { metricsLevel = MetricsLevel.ServiceAndApi; } else { metricsLevel = MetricsLevel.Service; } } return(new MetricsProperties() { Version = tableMetrics.Version, RetentionDays = tableMetrics.RetentionPolicy?.Days, MetricsLevel = metricsLevel, }); }
internal static MetricsProperties ReadMetricsPropertiesFromXml(XElement element) { if (element == null) { return(null); } MetricsLevel metricsLevel = MetricsLevel.None; if (bool.Parse(element.Element("Enabled").Value)) { metricsLevel = MetricsLevel.Service; if (bool.Parse(element.Element("IncludeAPIs").Value)) { metricsLevel = MetricsLevel.ServiceAndApi; } } return(new MetricsProperties { Version = element.Element("Version").Value, MetricsLevel = metricsLevel, RetentionDays = ReadRetentionPolicyFromXml(element.Element("RetentionPolicy")) }); }
/// <summary> /// Update the specified service properties according to the input /// </summary> /// <param name="serviceProperties">Service properties</param> internal void UpdateServiceProperties(MetricsProperties metrics) { if (Version != null) { metrics.Version = Version.ToString(); } if (RetentionDays != null) { if (RetentionDays == -1) { //Disable metrics retention policy metrics.RetentionDays = null; } else if (RetentionDays < 1 || RetentionDays > 365) { throw new ArgumentException(string.Format(Resources.InvalidRetentionDay, RetentionDays)); } else { metrics.RetentionDays = RetentionDays; } } if (MetricsLevel != null) { MetricsLevel metricsLevel = MetricsLevel.Value; metrics.MetricsLevel = metricsLevel; // Set default metrics version if (string.IsNullOrEmpty(metrics.Version)) { string defaultMetricsVersion = StorageNouns.DefaultMetricsVersion; metrics.Version = defaultMetricsVersion; } } }
public override int GetHashCode() { int hash = 1; hash ^= additionalMetricDims_.GetHashCode(); if (AggregationEnabled != false) { hash ^= AggregationEnabled.GetHashCode(); } if (AggregationMaxCount != 0UL) { hash ^= AggregationMaxCount.GetHashCode(); } if (AggregationMaxSize != 0UL) { hash ^= AggregationMaxSize.GetHashCode(); } if (CloudwatchEndpoint.Length != 0) { hash ^= CloudwatchEndpoint.GetHashCode(); } if (CloudwatchPort != 0UL) { hash ^= CloudwatchPort.GetHashCode(); } if (CollectionMaxCount != 0UL) { hash ^= CollectionMaxCount.GetHashCode(); } if (CollectionMaxSize != 0UL) { hash ^= CollectionMaxSize.GetHashCode(); } if (ConnectTimeout != 0UL) { hash ^= ConnectTimeout.GetHashCode(); } if (EnableCoreDumps != false) { hash ^= EnableCoreDumps.GetHashCode(); } if (FailIfThrottled != false) { hash ^= FailIfThrottled.GetHashCode(); } if (KinesisEndpoint.Length != 0) { hash ^= KinesisEndpoint.GetHashCode(); } if (KinesisPort != 0UL) { hash ^= KinesisPort.GetHashCode(); } if (LogLevel.Length != 0) { hash ^= LogLevel.GetHashCode(); } if (MaxConnections != 0UL) { hash ^= MaxConnections.GetHashCode(); } if (MetricsGranularity.Length != 0) { hash ^= MetricsGranularity.GetHashCode(); } if (MetricsLevel.Length != 0) { hash ^= MetricsLevel.GetHashCode(); } if (MetricsNamespace.Length != 0) { hash ^= MetricsNamespace.GetHashCode(); } if (MetricsUploadDelay != 0UL) { hash ^= MetricsUploadDelay.GetHashCode(); } if (MinConnections != 0UL) { hash ^= MinConnections.GetHashCode(); } if (RateLimit != 0UL) { hash ^= RateLimit.GetHashCode(); } if (RecordMaxBufferedTime != 0UL) { hash ^= RecordMaxBufferedTime.GetHashCode(); } if (RecordTtl != 0UL) { hash ^= RecordTtl.GetHashCode(); } if (Region.Length != 0) { hash ^= Region.GetHashCode(); } if (RequestTimeout != 0UL) { hash ^= RequestTimeout.GetHashCode(); } if (VerifyCertificate != false) { hash ^= VerifyCertificate.GetHashCode(); } return(hash); }