Represents a trace span.
Package
@google-cloud/trace-agentProperties
type
readonly
type
:
SpanType
;
The current span type. See SpanType
for more information.
Methods
addLabel(key, value)
addLabel
(
key
:
string
,
value
:
any
)
:
void
;
Adds a key-value pair as a label to the trace span. The value will be converted to a string if it is not already, and both the key and value may be truncated according to the user's configuration.
Name | Description |
---|---|
key | string
The label's key. |
value | any
The label's value. |
Type | Description |
---|---|
void |
endSpan(timestamp)
endSpan
(
timestamp
?:
Date
)
:
void
;
Ends the span. This method should only be called once.
Name | Description |
timestamp | Date
A custom span end time; defaults to the time when endSpan was called if not provided. |
Type | Description |
---|---|
void |
getTraceContext()
getTraceContext
()
:
TraceContext
|
null
;
Gets the current trace context, or null if it can't be retrieved. The trace context.
Type | Description |
---|---|
TraceContext | null |