Interface: Transaction

sentry.Transaction

Transaction “Class”, inherits Span only has setName

Hierarchy

  • TransactionContext

  • Omit<Span, "setName" | "name">

    Transaction

Properties

attributes

attributes: SpanAttributes

Attributes for the transaction.

Deprecated

Use getSpanAttributes(transaction) instead.

Overrides

TransactionContext.attributes


data

data: Object

Data for the transaction.

Deprecated

Use getSpanAttributes(transaction) instead.

Index signature

▪ [key: string]: any

Overrides

TransactionContext.data


description

Optional description: string

Description of the Span.

Deprecated

Use name instead.

Inherited from

TransactionContext.description


endTimestamp

Optional endTimestamp: number

Timestamp in seconds (epoch time) indicating when the span ended.

Inherited from

TransactionContext.endTimestamp


exclusiveTime

Optional exclusiveTime: number

Exclusive time in milliseconds.

Inherited from

TransactionContext.exclusiveTime


instrumenter

instrumenter: Instrumenter

The instrumenter that created this transaction.

Deprecated

This field will be removed in v8.

Overrides

TransactionContext.instrumenter


measurements

Optional measurements: Measurements

Measurements of the Span.

Inherited from

TransactionContext.measurements


metadata

metadata: TransactionMetadata

Metadata about the transaction.

Deprecated

Use attributes or store data on the scope instead.

Overrides

TransactionContext.metadata


name

name: string

Human-readable identifier for the transaction.

Deprecated

Use spanToJSON(span).description instead.

Overrides

TransactionContext.name


op

Optional op: string

Operation of the Span.

Inherited from

TransactionContext.op


origin

Optional origin: SpanOrigin

The origin of the span, giving context about what created the span.

Inherited from

TransactionContext.origin


parentSampled

Optional parentSampled: boolean

If this transaction has a parent, the parent’s sampling decision

Inherited from

TransactionContext.parentSampled


parentSpanId

Optional parentSpanId: string

Parent Span ID

Inherited from

TransactionContext.parentSpanId


sampled

Optional sampled: boolean

Was this transaction chosen to be sent as part of the sample?

Deprecated

Use spanIsSampled(transaction) instead.

Overrides

TransactionContext.sampled


spanId

spanId: string

The ID of the transaction.

Deprecated

Use spanContext().spanId instead.

Overrides

TransactionContext.spanId


startTimestamp

startTimestamp: number

Inherit Doc

Overrides

TransactionContext.startTimestamp


status

Optional status: string

Completion status of the Span. See: {@sentry/tracing SpanStatus} for possible values

Inherited from

TransactionContext.status


tags

tags: Object

Tags for the transaction.

Deprecated

Use getSpanAttributes(transaction) instead.

Index signature

▪ [key: string]: Primitive

Overrides

TransactionContext.tags


traceId

traceId: string

The ID of the trace.

Deprecated

Use spanContext().traceId instead.

Overrides

TransactionContext.traceId


transaction

Optional transaction: Transaction

The transaction containing this span

Deprecated

Use top level Sentry.getRootSpan() instead

Inherited from

Omit.transaction


trimEnd

Optional trimEnd: boolean

If true, sets the end timestamp of the transaction to the highest timestamp of child spans, trimming the duration of the transaction. This is useful to discard extra time in the transaction that is not accounted for in child spans, like what happens in the idle transaction Tracing integration, where we finish the transaction after a given “idle time” and we don’t want this “idle time” to be part of the transaction.

Inherited from

TransactionContext.trimEnd

Methods

end

end(endTimestamp?): void

End the current span.

Parameters

Name Type
endTimestamp? SpanTimeInput

Returns

void

Inherited from

Omit.end


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.

Inherited from

Omit.finish


getDynamicSamplingContext

getDynamicSamplingContext(): Partial<DynamicSamplingContext>

Return the current Dynamic Sampling Context of this transaction

Returns

Partial<DynamicSamplingContext>

Deprecated

Use top-level getDynamicSamplingContextFromSpan instead.


getProfileId

getProfileId(): undefined | string

Get the profile id from the transaction

Returns

undefined | string

Deprecated

Use toJSON() or access the fields directly instead.


getTraceContext

getTraceContext(): TraceContext

Convert the object to JSON for w. spans array info only.

Returns

TraceContext

Deprecated

Use spanToTraceContext() util function instead.

Inherited from

Omit.getTraceContext


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

Inherited from

Omit.isRecording


isSuccess

isSuccess(): boolean

Determines whether span was successful (HTTP200)

Returns

boolean

Deprecated

Use spanToJSON(span).status === 'ok' instead.

Inherited from

Omit.isSuccess


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

Inherited from

Omit.setAttribute


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

Inherited from

Omit.setAttributes


setContext

setContext(key, context): void

Set the context of a transaction event.

Parameters

Name Type
key string
context Context

Returns

void

Deprecated

Use either .setAttribute(), or set the context on the scope before creating the transaction.


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.

Inherited from

Omit.setData


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.

Inherited from

Omit.setHttpStatus


setMeasurement

setMeasurement(name, value, unit): void

Set observed measurement for this transaction.

Parameters

Name Type Description
name string Name of the measurement
value number Value of the measurement
unit MeasurementUnit Unit of the measurement. (Defaults to an empty string)

Returns

void

Deprecated

Use top-level setMeasurement() instead.


setMetadata

setMetadata(newMetadata): void

Set metadata for this transaction.

Parameters

Name Type
newMetadata Partial<TransactionMetadata>

Returns

void

Deprecated

Use attributes or store data on the scope instead.


setName

setName(name, source?): void

Set the name of the transaction

Parameters

Name Type
name string
source? TransactionSource

Returns

void

Deprecated

Use .updateName() and .setAttribute() 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

Inherited from

Omit.setStatus


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.

Inherited from

Omit.setTag


spanContext

spanContext(): SpanContextData

Get context data for this span. This includes the spanId & the traceId.

Returns

SpanContextData

Inherited from

Omit.spanContext


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

Span

Deprecated

Use startSpan(), startSpanManual() or startInactiveSpan() instead.

Inherited from

Omit.startChild


toContext

toContext(): TransactionContext

Returns the current transaction properties as a TransactionContext.

Returns

TransactionContext

Deprecated

Use toJSON() or access the fields directly instead.

Overrides

Omit.toContext


toJSON

toJSON(): SpanJSON

Convert the object to JSON.

Returns

SpanJSON

Deprecated

Use spanToJSON(span) instead.

Inherited from

Omit.toJSON


toTraceparent

toTraceparent(): string

Return a traceparent compatible header string.

Returns

string

Deprecated

Use spanToTraceHeader() instead.

Inherited from

Omit.toTraceparent


updateName

updateName(name): this

Update the name of the span.

Parameters

Name Type
name string

Returns

this

Inherited from

Omit.updateName


updateWithContext

updateWithContext(transactionContext): this

Updates the current transaction with a new TransactionContext.

Parameters

Name Type
transactionContext TransactionContext

Returns

this

Deprecated

Update the fields directly instead.

Overrides

Omit.updateWithContext