Exemple #1
0
        internal InfluxNullLineFormatter(string measurement, byte[] optionsDefaultTags)
        {
            _measurement       = InfluxName.Escape(measurement);
            _measurementLength = _measurement.Length;
            _defaultTags       = optionsDefaultTags;
            _hasDefaultTags    = _defaultTags != null && (_defaultTagsLength = _defaultTags.Length) > 0;

            _baseLength = _measurementLength + _defaultTagsLength + 2;
        }
Exemple #2
0
        internal InfluxLineWriter(string measurement, Type argsType, DiagnosticListenerOptions options)
        {
            _measurement       = InfluxName.Escape(measurement);
            _measurementLength = _measurement.Length;
            _objectFormatter   = new ObjectFormatter(argsType, options);
            _defaultTags       = options.DefaultTags;
            _hasDefaultTags    = _defaultTags != null && (_defaultTagsLength = _defaultTags.Length) > 0;

            _baseLength = _measurementLength + _defaultTagsLength + 2;
        }
        public void Add(string name, string value)
        {
            var nameBytes  = InfluxName.Escape(name);
            var valueBytes = InfluxName.Escape(value);

            var offset   = _defaultTags.Length;
            var size     = offset + nameBytes.Length + valueBytes.Length + 2;
            var newArray = new byte[size];

            _defaultTags.CopyTo(newArray, 0);

            newArray[offset] = (byte)',';
            offset++;
            nameBytes.CopyTo(newArray, offset);

            offset          += nameBytes.Length;
            newArray[offset] = (byte)'=';
            offset++;

            valueBytes.CopyTo(newArray, offset);

            Interlocked.Exchange(ref _defaultTags, newArray);
        }