Esempio n. 1
0
        public void ParseAnnotationDatagram()
        {
            var datagramParser = new DatagramParser(new MetricParser());
            var datagram       = datagramParser.ParseDatagram(Encoding.UTF8.GetBytes("datagram:annotation-v1:\n\0\0\0Deployment" + (char)24 + "\0\0\0Statsify Core Deployment"));

            Assert.IsInstanceOf <AnnotationDatagram>(datagram);

            var annotationDatagram = (AnnotationDatagram)datagram;

            Assert.AreEqual("Deployment", annotationDatagram.Title);
            Assert.AreEqual("Statsify Core Deployment", annotationDatagram.Message);
        }
Esempio n. 2
0
        private object PostMetrics(IMetricAggregator metricAggregator)
        {
            byte[] buffer;
            using (var memoryStream = new MemoryStream())
            {
                Request.Body.CopyTo(memoryStream);
                buffer = memoryStream.ToArray();
            } // using

            var datagramParser = new DatagramParser(new MetricParser());
            var metrics        = (MetricDatagram)datagramParser.ParseDatagram(buffer);

            foreach (var metric in metrics.Metrics)
            {
                metricAggregator.Aggregate(metric);
            }

            return(204);
        }