/// <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());
        }
Ejemplo n.º 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());
        }
 public MetricSnapshotStatsDStringWriter(Stream stream, StatsDPointSampler sampler, MetricsStatsDOptions options)
 {
     _stream  = stream;
     Sampler  = sampler;
     _options = options;
     _metricMetricStringSerializer = options.MetricNameFormatter ?? StatsDFormatterConstants.Defaults.MetricPointTextWriter;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 5
0
 public MetricsStatsDStringOutputFormatter(
     MetricsStatsDOptions options,
     MetricFields metricFields)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     MetricFields = metricFields ?? new MetricFields();
     _samplers    = new StatsDPointSampler(_options);
 }
 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();
 }
        /// <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());
        }
 public MetricsStatsDStringOutputFormatter(MetricsStatsDOptions options)
     : this(options, null)
 {
 }