Subsegment.prototype.addAnnotation = function()

in packages/core/lib/segments/attributes/subsegment.js [124:138]


Subsegment.prototype.addAnnotation = function(key, value) {
  if (!(typeof value === 'boolean' || typeof value === 'string' || (typeof value === 'number' && isFinite(value)))) {
    throw new Error('Failed to add annotation key: ' + key + ' value: ' + value + ' to subsegment ' +
      this.name + '. Value must be of type string, number or boolean.');
  } else if (typeof key !== 'string') {
    throw new Error('Failed to add annotation key: ' + key + ' value: ' + value + ' to subsegment ' +
      this.name + '. Key must be of type string.');
  }

  if (this.annotations === undefined) {
    this.annotations = {};
  }

  this.annotations[key] = value;
};