コード例 #1
0
        /// <summary>
        /// Update the Table service metrics properties according to the input
        /// </summary>
        /// <param name="metrics"></param>
        internal void UpdateServiceProperties(TableMetrics metrics)
        {
            if (Version != null)
            {
                metrics.Version = Version.ToString();
            }

            if (RetentionDays != null)
            {
                if (RetentionDays == -1)
                {
                    //Disable metrics retention policy
                    metrics.Enabled = false;
                    metrics.RetentionPolicy.Enabled = false;
                    metrics.RetentionPolicy.Days    = null;
                }
                else if (RetentionDays < 1 || RetentionDays > 365)
                {
                    throw new ArgumentException(string.Format(Resources.InvalidRetentionDay, RetentionDays));
                }
                else
                {
                    metrics.Enabled = true;
                    metrics.RetentionPolicy.Enabled = true;
                    metrics.RetentionPolicy.Days    = RetentionDays;
                }
            }

            if (MetricsLevel != null)
            {
                switch (MetricsLevel.Value)
                {
                case Azure.Storage.Shared.Protocol.MetricsLevel.Service:
                    metrics.IncludeApis = false;
                    break;

                case Azure.Storage.Shared.Protocol.MetricsLevel.ServiceAndApi:
                    metrics.IncludeApis = true;
                    break;

                case Azure.Storage.Shared.Protocol.MetricsLevel.None:
                    metrics.IncludeApis = null;
                    break;

                default:
                    throw new ArgumentException($"Unsupported metrics level {MetricsLevel.Value}");
                }
            }
        }
コード例 #2
0
 private MetricsLevel ParseMetricsLevel(TableMetrics tableMetrics)
 {
     if (!tableMetrics.Enabled)
     {
         return(MetricsLevel.None);
     }
     else if (tableMetrics.IncludeApis.HasValue && tableMetrics.IncludeApis.Value)
     {
         return(MetricsLevel.ServiceAndApi);
     }
     else
     {
         return(MetricsLevel.Service);
     }
 }
コード例 #3
0
        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,
            });
        }