コード例 #1
0
        /// <inheritdoc />
        public string Serialize(StatsDPoint point, MetricsStatsDOptions options)
        {
            var builder = new StringBuilder();

            builder.Append(point.Name);
            builder.Append(":");
            builder.Append(StatsDSyntax.FormatValue(point.Value, point.MetricType));
            builder.Append("|");
            builder.Append(point.MetricType);

            if (point.SampleRate.HasValue && point.SampleRate < 1.0)
            {
                builder.Append("|@");
                builder.Append(point.SampleRate.Value.ToString("0.###############", NumberFormatInfo.InvariantInfo));
            }

            if (point.Tags != null && point.Tags.Count > 0)
            {
                builder.Append('|');
                builder.Append(options.TagMarker);
                builder.Append(string.Join(",", point.Tags.Select(tag => $"{tag.Key}:{tag.Value}")));
            }

            return(builder.ToString());
        }
コード例 #2
0
        /// <inheritdoc />
        public string Serialize(StatsDPoint point, MetricsStatsDOptions options)
        {
            var builder = new StringBuilder();

            builder.Append(point.Name);
            builder.Append(":");
            builder.Append(StatsDSyntax.FormatValue(point.Value, point.MetricType));
            builder.Append("|");
            builder.Append(point.MetricType);

            if (point.SampleRate.HasValue && point.SampleRate < 1.0)
            {
                builder.Append("|@");
                builder.Append(point.SampleRate.Value.ToString("0.###############"));
            }

            var tags = new List <string>();

            if (point.Tags != null && point.Tags.Count > 0)
            {
                tags.AddRange(point.Tags.Select(tag => $"{tag.Key}:{tag.Value}"));
            }

            tags.Add($"{StatsDFormatterConstants.TimestampTagName}:{StatsDSyntax.FormatTimestamp(point.UtcTimestamp)}");

            builder.Append('|');
            builder.Append(options.TagMarker);
            builder.Append(string.Join(",", tags));

            return(builder.ToString());
        }
コード例 #3
0
 public MetricSnapshotStatsDStringWriter(Stream stream, StatsDPointSampler sampler, MetricsStatsDOptions options)
 {
     _stream  = stream;
     Sampler  = sampler;
     _options = options;
     _metricMetricStringSerializer = options.MetricNameFormatter ?? StatsDFormatterConstants.Defaults.MetricPointTextWriter;
 }
コード例 #4
0
 public MetricSnapshotStatsDStringWriter(Stream stream, StatsDPointSampler sampler, MetricsStatsDOptions options)
 {
     _stream  = stream ?? throw new ArgumentNullException(nameof(stream));
     _sampler = sampler;
     _options = options;
     _metricMetricStringSerializer = options.MetricNameFormatter ?? StatsDFormatterConstants.Defaults.MetricPointTextWriter;
 }
コード例 #5
0
 public MetricsStatsDStringOutputFormatter(
     MetricsStatsDOptions options,
     MetricFields metricFields)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     MetricFields = metricFields ?? new MetricFields();
     _samplers    = new StatsDPointSampler(_options);
 }
コード例 #6
0
 public MetricsStatsDStringOutputFormatter(
     MetricsStatsDOptions options,
     MetricFields metricFields)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     MetricFields = metricFields ?? new MetricFields();
     _samplers    = new StatsDPointSampler(_options);
     _nullWriter  = new MetricSnapshotStatsDStringWriter(null, _samplers, _options);
     _serializer  = new MetricSnapshotSerializer();
 }
コード例 #7
0
        /// <inheritdoc />
        public string Serialize(StatsDPoint point, MetricsStatsDOptions options)
        {
            var builder = new StringBuilder();

            builder.Append(point.Name);
            builder.Append(":");
            builder.Append(StatsDSyntax.FormatValue(point.Value, point.MetricType));
            builder.Append("|");
            builder.Append(point.MetricType);

            if (point.SampleRate.HasValue && point.SampleRate < 1.0)
            {
                builder.Append("|@");
                builder.Append(point.SampleRate.Value.ToString("0.###############", NumberFormatInfo.InvariantInfo));
            }
            return(builder.ToString());
        }
コード例 #8
0
 public MetricsStatsDStringOutputFormatter(MetricsStatsDOptions options)
     : this(options, null)
 {
 }