Subsegment.prototype.addAnnotation = function()

in packages/core/lib/segments/attributes/subsegment.js [140:158]


Subsegment.prototype.addAnnotation = function(key, value) {
  if (typeof value !== 'boolean' && typeof value !== 'string' && !isFinite(value)) {
    logger.getLogger().error('Failed to add annotation key: ' + key + ' value: ' + value + ' to subsegment ' +
      this.name + '. Value must be of type string, number or boolean.');
    return;
  }

  if (typeof key !== 'string') {
    logger.getLogger().error('Failed to add annotation key: ' + key + ' value: ' + value + ' to subsegment ' +
      this.name + '. Key must be of type string.');
    return;
  }

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

  this.annotations[key] = value;
};