/// <inheritdoc/>
        public Task WriteAsync(
            Stream output,
            MetricsDataValueSource metricsData,
            CancellationToken cancellationToken = default)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var serializer = new MetricSnapshotSerializer();

            using (var streamWriter = new StreamWriter(output))
            {
                using (var textWriter = new MetricSnapshotInfluxDbLineProtocolWriter(
                           streamWriter,
                           _options.MetricNameFormatter,
                           _options.MetricNameMapping))
                {
                    serializer.Serialize(textWriter, metricsData);
                }
            }

#if !NETSTANDARD1_6
            return(AppMetricsTaskHelper.CompletedTask());
#else
            return(Task.CompletedTask);
#endif
        }
        /// <inheritdoc/>
        public async Task WriteAsync(
            Stream output,
            MetricsDataValueSource metricsData,
            CancellationToken cancellationToken = default)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var serializer = new MetricSnapshotSerializer();

            await using var streamWriter = new StreamWriter(output, Encoding, bufferSize: 1024, leaveOpen: true);
            await using var textWriter   = new MetricSnapshotInfluxDbLineProtocolWriter(
                            streamWriter,
                            _options.MetricNameFormatter);
            serializer.Serialize(textWriter, metricsData, MetricFields);
        }