コード例 #1
0
        public MetricsContext(
            string logNamespace,
            Dictionary <string, object> properties,
            List <DimensionSet> dimensionSets,
            DimensionSet defaultDimensionSet) : this()
        {
            if (string.IsNullOrEmpty(logNamespace))
            {
                throw new ArgumentNullException(nameof(logNamespace));
            }
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }
            if (dimensionSets == null)
            {
                throw new ArgumentNullException(nameof(dimensionSets));
            }
            if (defaultDimensionSet == null)
            {
                throw new ArgumentNullException(nameof(defaultDimensionSet));
            }

            Namespace         = logNamespace;
            DefaultDimensions = defaultDimensionSet;
            foreach (DimensionSet dimension in dimensionSets)
            {
                PutDimension(dimension);
            }

            foreach (var property in properties)
            {
                PutProperty(property.Key, property.Value);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds a dimension set with single dimension-value entry to the metric context.
        /// </summary>
        /// <example>
        /// metricContext.PutDimension("ExampleDimension", "ExampleValue")
        /// </example>
        /// <param name="dimension">the name of the new dimension.</param>
        /// <param name="value">the value of the new dimension.</param>
        public void PutDimension(string dimension, string value)
        {
            var dimensionSet = new DimensionSet();

            dimensionSet.AddDimension(dimension, value);
            _metricDirective.CustomDimensionSets.Add(dimensionSet);
        }
コード例 #3
0
 public MetricDirective()
 {
     Namespace                     = Constants.DEFAULT_NAMESPACE;
     _metrics                      = new List <MetricDefinition>();
     CustomDimensionSets           = new List <DimensionSet>();
     DefaultDimensionSet           = new DimensionSet();
     _shouldUseDefaultDimensionSet = true;
 }
コード例 #4
0
 MetricDirective()
 {
     Namespace                 = "aws-embedded-metrics";
     Metrics                   = new Dictionary <String, MetricDefinition>();
     Dimensions                = new List <DimensionSet>();
     DefaultDimensions         = new DimensionSet();
     ShouldUseDefaultDimension = true;
 }
コード例 #5
0
        /// <summary>
        /// Append all the dimensions from the specified dimension set to this one and return this dimension set.
        /// </summary>
        /// <param name="other">The dimension set to append to this one</param>
        /// <returns>this dimension set with the other appended</returns>
        public DimensionSet AddRange(DimensionSet other)
        {
            foreach (var dimension in other?.Dimensions)
            {
                Dimensions[dimension.Key] = dimension.Value;
            }

            return(this);
        }
コード例 #6
0
        public DimensionSet DeepClone()
        {
            var clone = new DimensionSet();

            foreach (var dimension in Dimensions)
            {
                clone.Dimensions.Add(dimension.Key, dimension.Value);
            }

            return(clone);
        }
コード例 #7
0
 /// <summary>
 /// Add dimensions to the metric context.
 /// </summary>
 /// <param name="dimensionSet">the dimensions set to add.</param>
 public void PutDimension(DimensionSet dimensionSet)
 {
     _metricDirective.CustomDimensionSets.Add(dimensionSet);
 }
コード例 #8
0
 void PutDimensionSet(DimensionSet dimensionSet)
 {
     Dimensions.Add(dimensionSet);
 }