in packages/core/lib/segments/segment.js [117:137]
Segment.prototype.addMetadata = function(key, value, namespace) {
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.');
} else if (namespace && typeof namespace !== 'string') {
throw new Error('Failed to add annotation key: ' + key + ' value: ' + value + 'namespace: ' + namespace + ' to subsegment ' +
this.name + '. Namespace must be of type string.');
}
var ns = namespace || 'default';
if (!this.metadata) {
this.metadata = {};
}
if (!this.metadata[ns]) {
this.metadata[ns] = {};
}
this.metadata[ns][key] = value;
};