Interface: Span
sentry.Span
Span holding trace_id, span_id
Hierarchy
-
Omit
<SpanContext
,"op"
|"status"
|"origin"
>↳
Span
Properties
attributes
• attributes: SpanAttributes
Attributes for the span.
Deprecated
Use spanToJSON(span).atttributes
instead.
Overrides
Omit.attributes
data
• data: Object
Data for the span.
Deprecated
Use spanToJSON(span).atttributes
instead.
Index signature
▪ [key: string
]: any
Overrides
Omit.data
description
• Optional
description: string
Description of the Span.
Deprecated
Use name
instead.
Inherited from
Omit.description
endTimestamp
• Optional
endTimestamp: number
Timestamp in seconds (epoch time) indicating when the span ended.
Deprecated
Use spanToJSON()
instead.
Overrides
Omit.endTimestamp
exclusiveTime
• Optional
exclusiveTime: number
Exclusive time in milliseconds.
Inherited from
Omit.exclusiveTime
instrumenter
• instrumenter: Instrumenter
The instrumenter that created this span.
Deprecated
this field will be removed.
Overrides
Omit.instrumenter
measurements
• Optional
measurements: Measurements
Measurements of the Span.
Inherited from
Omit.measurements
name
• name: string
Human-readable identifier for the span. Identical to span.description.
Deprecated
Use spanToJSON(span).description
instead.
Overrides
Omit.name
op
• Optional
op: string
Operation of the Span.
Deprecated
Use startSpan()
functions to set, span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'op') to update and
spanToJSON().op` to read the op instead
origin
• Optional
origin: SpanOrigin
The origin of the span, giving context about what created the span.
Deprecated
Use startSpan
function to set and spanToJSON(span).origin
to read the origin instead.
parentSpanId
• Optional
parentSpanId: string
Parent Span ID
Deprecated
Use spanToJSON(span).parent_span_id
instead.
Overrides
Omit.parentSpanId
sampled
• Optional
sampled: boolean
Was this span chosen to be sent as part of the sample?
Deprecated
Use isRecording()
instead.
Overrides
Omit.sampled
spanId
• spanId: string
The ID of the span.
Deprecated
Use spanContext().spanId
instead.
Overrides
Omit.spanId
startTimestamp
• startTimestamp: number
Timestamp in seconds (epoch time) indicating when the span started.
Deprecated
Use spanToJSON()
instead.
Overrides
Omit.startTimestamp
status
• Optional
status: string
Completion status of the Span.
See: {@sentry/tracing SpanStatus} for possible values
Deprecated
Use .setStatus
to set or update and spanToJSON()
to read the status.
tags
• tags: Object
Tags for the span.
Deprecated
Use spanToJSON(span).atttributes
instead.
Index signature
▪ [key: string
]: Primitive
Overrides
Omit.tags
traceId
• traceId: string
The ID of the trace.
Deprecated
Use spanContext().traceId
instead.
Overrides
Omit.traceId
transaction
• Optional
transaction: Transaction
The transaction containing this span
Deprecated
Use top level Sentry.getRootSpan()
instead
Methods
end
▸ end(endTimestamp?
): void
End the current span.
Parameters
Name | Type |
---|---|
endTimestamp? |
SpanTimeInput |
Returns
void
finish
▸ finish(endTimestamp?
): void
Sets the finish timestamp on the current span.
Parameters
Name | Type | Description |
---|---|---|
endTimestamp? |
number |
Takes an endTimestamp if the end should not be the time when you call this function. |
Returns
void
Deprecated
Use .end()
instead.
getTraceContext
▸ getTraceContext(): TraceContext
Convert the object to JSON for w. spans array info only.
Returns
TraceContext
Deprecated
Use spanToTraceContext()
util function instead.
isRecording
▸ isRecording(): boolean
If this is span is actually recording data. This will return false if tracing is disabled, this span was not sampled or if the span is already finished.
Returns
boolean
isSuccess
▸ isSuccess(): boolean
Determines whether span was successful (HTTP200)
Returns
boolean
Deprecated
Use spanToJSON(span).status === 'ok'
instead.
setAttribute
▸ setAttribute(key
, value
): void
Set a single attribute on the span.
Set it to undefined
to remove the attribute.
Parameters
Name | Type |
---|---|
key |
string |
value |
undefined | SpanAttributeValue |
Returns
void
setAttributes
▸ setAttributes(attributes
): void
Set multiple attributes on the span.
Any attribute set to undefined
will be removed.
Parameters
Name | Type |
---|---|
attributes |
SpanAttributes |
Returns
void
setData
▸ setData(key
, value
): this
Sets the data attribute on the current span
Parameters
Name | Type | Description |
---|---|---|
key |
string |
Data key |
value |
any |
Data value |
Returns
this
Deprecated
Use setAttribute()
instead.
setHttpStatus
▸ setHttpStatus(httpStatus
): this
Sets the status attribute on the current span based on the http code
Parameters
Name | Type | Description |
---|---|---|
httpStatus |
number |
http code used to set the status |
Returns
this
Deprecated
Use top-level setHttpStatus()
instead.
setName
▸ setName(name
): void
Set the name of the span.
Parameters
Name | Type |
---|---|
name |
string |
Returns
void
Deprecated
Use updateName()
instead.
setStatus
▸ setStatus(status
): this
Sets the status attribute on the current span See: {@sentry/tracing SpanStatus} for possible values
Parameters
Name | Type | Description |
---|---|---|
status |
string |
http code used to set the status |
Returns
this
setTag
▸ setTag(key
, value
): this
Sets the tag attribute on the current span.
Can also be used to unset a tag, by passing undefined
.
Parameters
Name | Type | Description |
---|---|---|
key |
string |
Tag key |
value |
Primitive |
Tag value |
Returns
this
Deprecated
Use setAttribute()
instead.
spanContext
▸ spanContext(): SpanContextData
Get context data for this span. This includes the spanId & the traceId.
Returns
SpanContextData
startChild
▸ startChild(spanContext?
): Span
Creates a new Span
while setting the current Span.id
as parentSpanId
.
Also the sampled
decision will be inherited.
Parameters
Name | Type |
---|---|
spanContext? |
Pick <SpanContext , "name" | "tags" | "data" | "origin" | "measurements" | "op" | "status" | "description" | "spanId" | "attributes" | "startTimestamp" | "endTimestamp" | "instrumenter" | "exclusiveTime" > |
Returns
Deprecated
Use startSpan()
, startSpanManual()
or startInactiveSpan()
instead.
toContext
▸ toContext(): SpanContext
Returns the current span properties as a SpanContext
.
Returns
SpanContext
Deprecated
Use toJSON()
or access the fields directly instead.
toJSON
▸ toJSON(): SpanJSON
Convert the object to JSON.
Returns
SpanJSON
Deprecated
Use spanToJSON(span)
instead.
toTraceparent
▸ toTraceparent(): string
Return a traceparent compatible header string.
Returns
string
Deprecated
Use spanToTraceHeader()
instead.
updateName
▸ updateName(name
): this
Update the name of the span.
Parameters
Name | Type |
---|---|
name |
string |
Returns
this
updateWithContext
▸ updateWithContext(spanContext
): this
Updates the current span with a new SpanContext
.
Parameters
Name | Type |
---|---|
spanContext |
SpanContext |
Returns
this
Deprecated
Update the fields directly instead.