Esempio n. 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 !);
        }
Esempio n. 2
0
        internal Metric(ITransport transport, ITelemetry telemetry, string metricName, MetricType metricType,
                        double sampleRate, IList <KeyValuePair <string, string> >?tags)
        {
            _transport  = transport;
            _telemetry  = telemetry;
            _metricName = metricName;
            _sampleRate = sampleRate;
            _tags       = tags;

            _metricPrefixBytes = DogStatsDSerializer.SerializeMetricPrefix(metricName);
            _metricSuffixBytes = DogStatsDSerializer.SerializeMetricSuffix(metricType, sampleRate, tags);
        }