Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addEvent(
name: string,
attributesOrStartTime?: types.Attributes | types.TimeInput,
startTime?: types.TimeInput
): this {
if (this._isSpanEnded()) return this;
if (this.events.length >= this._traceParams.numberOfEventsPerSpan!) {
this._logger.warn('Dropping extra events.');
this.events.shift();
}
if (isTimeInput(attributesOrStartTime)) {
if (typeof startTime === 'undefined') {
startTime = attributesOrStartTime as types.TimeInput;
}
attributesOrStartTime = undefined;
}
if (typeof startTime === 'undefined') {
startTime = hrTime();
}
this.events.push({
name,
attributes: attributesOrStartTime as types.Attributes,
time: timeInputToHrTime(startTime),
});
return this;
}