Class: NoopSpan
A fake implementation of the Span API which does nothing. This can be used as the default span.
Implements
Constructors
constructor
• new NoopSpan(): NoopSpan
Returns
Methods
close
▸ close(args?
): number
Alias for end
.
Parameters
Name | Type |
---|---|
args? | EndSpanArgs |
Returns
number
Implementation of
end
▸ end(args?
): number
Log an end time to the span (defaults to the current time). Returns the logged time.
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.
Implementation of
log
▸ log(_
): void
Incrementally update the current span with new data. The event will be batched and uploaded behind the scenes.
Parameters
Name | Type |
---|---|
_ | ExperimentLogPartialArgs |
Returns
void
Implementation of
logFeedback
▸ logFeedback(event
): void
Add feedback to the current span. Unlike Experiment.logFeedback
and Logger.logFeedback
, this method does not accept an id parameter, because it logs feedback to the current span.
Parameters
Name | Type |
---|---|
event | Omit <LogFeedbackFullArgs , "id" > |
Returns
void
Implementation of
startSpan
▸ startSpan(_1?
): NoopSpan
Lower-level alternative to traced
. This allows you to start a span yourself, and can be useful in situations
where you cannot use callbacks. However, spans started with startSpan
will not be marked as the "current span",
so currentSpan()
and traced()
will be no-ops. If you want to mark a span as current, use traced
instead.
See traced
for full details.
Parameters
Name | Type |
---|---|
_1? | StartSpanArgs |
Returns
The newly-created Span
Implementation of
traced
▸ traced<R
>(callback
, _1?
): R
Create a new span and run the provided callback. 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.
Spans created within traced
are ended automatically. By default, the span is marked as current, so they can be accessed using braintrust.currentSpan
.
Type parameters
Name |
---|
R |
Parameters
Name | Type | Description |
---|---|---|
callback | (span : Span ) => R | The function to be run under the span context. |
_1? | StartSpanArgs & SetCurrentArg | - |
Returns
R
Returns
The result of running callback
.
Implementation of
Properties
id
• id: string
Row ID of the span.
Implementation of
kind
• kind: "span"
Implementation of
root_span_id
• root_span_id: string
Span ID of the root span in the full trace.
Implementation of
span_id
• span_id: string
Span ID of the span. This is used to link spans together.