Exemple #1
0
        public void SerializeMetric(string name, double value, MetricType type, double sampleRate, string?tags,
                                    string expected)
        {
            byte[] prefixBytes = DogStatsDSerializer.SerializeMetricPrefix(name);
            byte[] suffixBytes = DogStatsDSerializer.SerializeMetricSuffix(type, sampleRate, TestHelper.ParseTags(tags));
            ArraySegment <byte> metricBytes = DogStatsDSerializer.SerializeMetric(prefixBytes, value, suffixBytes);

            Assert.AreEqual(expected, Encoding.ASCII.GetString(metricBytes.Array !, metricBytes.Offset, metricBytes.Count));
            ArrayPool <byte> .Shared.Return(metricBytes.Array !);
        }
Exemple #2
0
        private protected void Submit(double value)
        {
            _telemetry.MetricSent();

            if (!Sampling.Sample(_sampleRate))
            {
                return;
            }

            var metricBytes = DogStatsDSerializer.SerializeMetric(_metricPrefixBytes, value, _metricSuffixBytes);

            _transport.Send(metricBytes);
        }