Interface: Span
A Span encapsulates logged data and metrics for a unit of work. This interface is shared by all span implementations.
We suggest using one of the various startSpan
methods, instead of creating Spans directly. See Span.startSpan
for full details.
Implemented by
Methods
close
▸ close(args?
): number
Alias for end
.
Parameters
Name | Type |
---|---|
args? | EndSpanArgs |
Returns
number
end
▸ end(args?
): number
Terminate the span. Returns the end time logged to the row's metrics. After calling end, you may not invoke any further methods on the span object, except for the property accessors.
Will be invoked automatically if the span is constructed with traced.
Parameters
Name | Type |
---|---|
args? | EndSpanArgs |
Returns
number
The end time logged to the span metrics.
log
▸ log(event
): void
Incrementally update the current span with new data. The event will be batched and uploaded behind the scenes.
Parameters
Name | Type |
---|---|
event | ExperimentLogPartialArgs |
Returns
void
startSpan
▸ startSpan(name
, args?
): Span
Create a new span. This is useful if you want to log more detailed trace information beyond the scope of a single log event. Data logged over several calls to Span.log
will be merged into one logical row.
We recommend running spans within a callback (using traced
) to automatically mark them as current and ensure they are terminated. If you wish to start a span outside a callback, be sure to terminate it with span.end()
.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the span. |
args? | StartSpanArgs | - |
Returns
The newly-created Span
traced
▸ traced<R
>(name
, callback
, args?
): R
Wrapper over Span.startSpan
, which passes the initialized Span
it to the given callback and ends it afterwards. See Span.startSpan
for full details.
Type parameters
Name |
---|
R |
Parameters
Name | Type |
---|---|
name | string |
callback | (span : Span ) => R |
args? | StartSpanArgs & SetCurrentArg |
Returns
R
Properties
id
• id: string
Row ID of the span.
kind
• kind: "span"
root_span_id
• root_span_id: string
Span ID of the root span in the full trace.
span_id
• span_id: string
Span ID of the span. This is used to link spans together.