/// <summary> Increment the metric counter for the given name. </summary> /// /// <exception cref="ArgumentNullException"> Thrown when <paramref name="name"/> is null. </exception> /// /// <param name="name"> The name of the metric to record. Only the first 1000 characters are /// retained. </param> public void IncrementCounter(string name) { name = name ?? throw new ArgumentNullException(nameof(name)); using (new IgnoreWork()) { // NOTE: Unlike Custom timing metrics, Custom count metrics are NOT restricted to only the "Custom" namespace. // This is probably a historical blunder -- it's not a good thing that we allow users to use whatever text they want for the first segment. // However, that is what the API currently allows and it would be difficult to take that feature away. var metric = _metricBuilder.TryBuildCustomCountMetric(name); if (metric != null) { _metricAggregator.Collect(metric); } } }