Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
chore: use function overloads for addEvent and recordException
Browse files Browse the repository at this point in the history
  • Loading branch information
vreynolds committed Jun 24, 2021
1 parent 1397958 commit 81fc4d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/trace/NonRecordingSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export class NonRecordingSpan implements Span {
}

// By default does nothing
addEvent(_name: string, _attributes?: SpanAttributes): this {
addEvent(
_name: string,
_attributesOrTime?: SpanAttributes | TimeInput,
_time?: TimeInput
): this {
return this;
}

Expand Down
30 changes: 22 additions & 8 deletions src/trace/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,21 @@ export interface Span {
* Adds an event to the Span.
*
* @param name the name of the event.
* @param [attributesOrStartTime] the attributes that will be added; these are
* associated with this event. Can be also a start time
* if type is {@type TimeInput} and 3rd param is undefined
* @param [startTime] start time of the event.
*/
addEvent(name: string, startTime?: TimeInput): this;

/**
* Adds an event to the Span.
*
* @param name the name of the event.
* @param [attributes] the attributes that will be added; these are
* associated with this event.
* @param [startTime] start time of the event.
*/
addEvent(
name: string,
attributesOrStartTime?: SpanAttributes | TimeInput,
attributes?: SpanAttributes,
startTime?: TimeInput
): this;

Expand Down Expand Up @@ -123,15 +130,22 @@ export interface Span {
* Sets exception as a span event.
*
* @param exception the exception the only accepted values are string or Error
* @param [attributesOrTime] additional attributes to be associated with
* this event. Can also be the time parameter if type is {@type TimeInput}
* and 3rd parameter is undefined.
* @param [time] the time to set as Span's event time. If not provided,
* use the current time.
*/
recordException(exception: Exception, time?: TimeInput): void;

/**
* Sets exception as a span event.
*
* @param exception the exception the only accepted values are string or Error
* @param [attributes] additional attributes to be associated with this event.
* @param [time] the time to set as Span's event time. If not provided,
* use the current time.
*/
recordException(
exception: Exception,
attributesOrTime?: SpanAttributes | TimeInput,
attributes?: SpanAttributes,
time?: TimeInput
): void;
}

0 comments on commit 81fc4d3

Please sign in to comment.