Class: Subsegment

Subsegment(name)

new Subsegment(name)

Represents a subsegment.
Parameters:
Name Type Description
name string The name of the subsegment.
Source:

Methods

addAnnotation(key, value)

Adds a key-value pair that can be queryable through GetTraceSummaries. Only acceptable types are string, float/int and boolean.
Parameters:
Name Type Description
key string The name of key to add.
value boolean | string | number The value to add for the given key.
Source:

addAttribute(name, data)

Adds a property with associated data into the subsegment.
Parameters:
Name Type Description
name string The name of the property to add.
data Object The data of the property to add.
Source:

addError(err, remoteopt)

Adds an error with associated data into the subsegment. To handle propagating errors, the subsegment also sets a copy of the error on the root segment. As the error passes up the execution stack, a reference is created on each subsegment to the originating subsegment.
Parameters:
Name Type Attributes Description
err Error | string The error to capture.
remote boolean <optional>
Flag for whether the exception caught was remote or not.
Source:

addErrorFlag()

Adds error flag to the subsegment.
Source:

addFaultFlag()

Adds fault flag to the subsegment.
Source:

addMetadata(key, value, namespaceopt)

Adds a key-value pair to the metadata.default attribute when no namespace is given. Metadata is not queryable, but is recorded.
Parameters:
Name Type Attributes Description
key string The name of the key to add.
value object | null The value of the associated key.
namespace string <optional>
The property name to put the key/value pair under.
Source:

addNewSubsegment(name) → {Subsegment}

Nests a new subsegment to the array of subsegments.
Parameters:
Name Type Description
name string The name of the new subsegment to append.
Source:
Returns:
- The newly created subsegment.
Type
Subsegment

addPrecursorId(id)

Adds a subsegement id to record ordering.
Parameters:
Name Type Description
id string A subsegment id.
Source:

addRemoteRequestData(req, res, downstreamXRayEnabled)

Adds data for an outgoing HTTP/HTTPS call.
Parameters:
Name Type Description
req http.ClientRequest/https.ClientRequest The request object from the HTTP/HTTPS call.
res http.IncomingMessage/https.IncomingMessage The response object from the HTTP/HTTPS call.
downstreamXRayEnabled boolean when true, adds a "traced": true hint to generated subsegments such that the AWS X-Ray service expects a corresponding segment from the downstream service.
Source:

addSubsegment(subsegment)

Adds a subsegment to the array of subsegments.
Parameters:
Name Type Description
subsegment Subsegment The subsegment to append.
Source:

addThrottleFlag()

Adds throttle flag to the subsegment.
Source:

close(erropt, remoteopt)

Closes the current subsegment. This automatically captures any exceptions and sets the end time.
Parameters:
Name Type Attributes Description
err Error | string <optional>
The error to capture.
remote boolean <optional>
Flag for whether the exception caught was remote or not.
Source:

decrementCounter()

Each subsegment holds a counter of its open subsegments. This decrements the counter such that it can be called from a child and propagate up.
Source:

flush()

Sends the subsegment to the daemon.
Source:

format()

Returns the formatted, trimmed subsegment JSON string to send to the daemon.
Source:

incrementCounter(additionalopt)

Each subsegment holds a counter of open subsegments. This increments the counter such that it can be called from a child and propagate up.
Parameters:
Name Type Attributes Description
additional Number <optional>
An additional amount to increment. Used when adding subsegment trees.
Source:

isClosed() → {boolean}

Returns a boolean indicating whether or not the subsegment has been closed.
Source:
Returns:
- Returns true if the subsegment is closed.
Type
boolean

removeSubsegment()

Removes the subsegment from the subsegments array, used in subsegment streaming.
Source:

serialize()

Returns the serialized subsegment JSON string, replacing any BigInts with strings.
Source:

streamSubsegments()

Returns true if the subsegment was streamed in its entirety
Source:

toString()

Returns the formatted subsegment JSON string.
Source: