internal Metric GetOrCreateMetric(
            string metricId,
            string dimension1Name,
            string dimension2Name,
            IMetricConfiguration metricConfiguration)
        {
            metricId = metricId?.Trim();
            Util.ValidateNotNullOrWhitespace(metricId, nameof(metricId));

            string metricObjectId = Metric.GetObjectId(metricId, dimension1Name, dimension2Name);
            Metric metric         = _metrics.GetOrAdd(metricObjectId, (key) => new Metric(
                                                          _metricManager,
                                                          metricId,
                                                          dimension1Name,
                                                          dimension2Name,
                                                          metricConfiguration ?? MetricConfigurations.Common.Default()));

            if (metricConfiguration != null && !metric._configuration.Equals(metricConfiguration))
            {
                throw new ArgumentException("A Metric with the specified Id and dimension names already exists, but it has a configuration"
                                            + " that is different from the specified configuration. You may not change configurations once a"
                                            + " metric was created for the first time. Either specify the same configuration every time, or"
                                            + " specify 'null' during every invocation except the first one. 'Null' will match against any"
                                            + " previously specified configuration when retrieving existing metrics, or fall back to"
                                            + $" the default when creating new metrics. (Metric Object Id: \"{metricObjectId}\".)");
            }

            return(metric);
        }