예제 #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);
        }
 public MetricDirective()
 {
     Namespace                     = Constants.DEFAULT_NAMESPACE;
     _metrics                      = new List <MetricDefinition>();
     CustomDimensionSets           = new List <DimensionSet>();
     DefaultDimensionSet           = new DimensionSet();
     _shouldUseDefaultDimensionSet = true;
 }
 MetricDirective()
 {
     Namespace                 = "aws-embedded-metrics";
     Metrics                   = new Dictionary <String, MetricDefinition>();
     Dimensions                = new List <DimensionSet>();
     DefaultDimensions         = new DimensionSet();
     ShouldUseDefaultDimension = true;
 }
        /// <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);
        }
        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);
 }
 void PutDimensionSet(DimensionSet dimensionSet)
 {
     Dimensions.Add(dimensionSet);
 }