setAttribute method

  1. @override
void setAttribute(
  1. Attribute attribute
)
override

set single attribute

Implementation

@override
void setAttribute(api.Attribute attribute) {
  //Don't want to have any attribute
  if (_limits.maxNumAttributes == 0) {
    _droppedSpanAttributes++;
    return;
  }

  final obj = _attributes.get(attribute.key);
  // If current attributes.length is equal or greater than maxNumAttributes and
  // key is not in current map, drop it.
  if (_attributes.length >= _limits.maxNumAttributes && obj == null) {
    _droppedSpanAttributes++;
    return;
  }
  _attributes.add(_rebuildAttribute(attribute, _limits.maxNumAttributeLength));
}