Example #1
0
        public void Transform()
        {
            var data      = new Fixture().CreateMany <PerformanceStorageData>(10000).ToList();
            var stopWatch = new Stopwatch();

            for (var i = 0; i <= 1; i++)
            {
                data.AddRange(new Fixture().CreateMany <PerformanceStorageData>(10000).ToList());
            }
            stopWatch.Start();

            var sut        = new OpenTsdbClient(new HttpClient());
            var metricData = new ConcurrentBag <IEnumerable <MetricData> >();

            var options = new ParallelOptions
            {
                MaxDegreeOfParallelism = 1
            };

            Parallel.ForEach(data, options, d => {
                metricData.Add(sut.TransformToMany(d));
            });

            stopWatch.Stop();
            var metric = stopWatch.Elapsed;
        }
        public void Transform()
        {
            var data      = new Fixture().CreateMany <PerformanceStorageData>(1000).ToList();
            var stopWatch = new Stopwatch();

            for (var i = 0; i <= 2; i++)
            {
                data.AddRange(new Fixture().CreateMany <PerformanceStorageData>(1000).ToList());
            }
            stopWatch.Start();
            var sut        = new OpenTsdbClient(new HttpClient());
            var metricData = new List <MetricData>();

            foreach (var performanceStorageData in data)
            {
                metricData.AddRange(sut.TransformToMany(performanceStorageData));
            }
            stopWatch.Stop();
            var metric = stopWatch.Elapsed;
        }
Example #3
0
        static void Main(string[] args)
        {
            var tags = new Dictionary <string, string> {
                { "aaa", "a" }, { "ggg", "b" }
            };

            var clientUrl = "http://35.195.211.134:4242/";
            var client    = new OpenTsdbClient(clientUrl);

            var metrics = Enumerable.Range(0, 100)
                          .Select(_ => new MetricData
            {
                Metric    = "TestMetric123",
                Tags      = tags,
                Timestamp = GetUnixTimeStamp(DateTime.UtcNow.AddMinutes(-_)),
                Value     = _
            })
                          .ToArray();

            client.Put
            .Insert(metrics, true, 10000)
            .GetAwaiter()
            .GetResult();
        }