public void Test()
        {
            var formatter = new KeyFormatter();

            Assert.Throws <ArgumentNullException>(() => formatter.Format <string?>(null));

            var key = Guid.NewGuid();

            Assert.Equal(key.ToString(), formatter.Format(key.ToString()));
            Assert.Equal(key.ToString(), formatter.Format(key));
        }
Beispiel #2
0
        public static string Serialize(InfluxPoint point)
        {
            var tags   = point.Tags;
            var fields = point.Fields;

            var allTags   = string.Join(",", TagsFormatter.Format(tags));
            var allFields = string.Join(",", FieldFormatter.Format(fields));

            var tagsPart = allTags.Length > 0 ? $",{allTags}" : allTags;

            var measurement = KeyFormatter.Format(point.Measurement);

            return($"{measurement}{tagsPart} {allFields} {FieldValueFormatter.FormatTimestamp(point.UtcTimestamp)}".Trim());
        }
        public static string BuildMeasurement(params string[] names)
        {
            var metricName = string.Join(".", names.Where(n => string.IsNullOrWhiteSpace(n) == false).Select(s => SanitizeMeasurement(s.Trim('.').Trim(' '))));

            return(KeyFormatter.Format(metricName));
        }
Beispiel #4
0
        public void MultipleKeysShouldFormatAsAnonymousType()
        {
            var formatter = new KeyFormatter();

            formatter.Format("key1", "key2").Should().Be("x => new { x.key1, x.key2 }");
        }
Beispiel #5
0
        public void OneKeyShouldFormatAsScalar()
        {
            var formatter = new KeyFormatter();

            formatter.Format("key1").Should().Be("x => x.key1");
        }
Beispiel #6
0
 public string Format(string key)
 {
     return(KeyFormatter.Format(key));
 }