aws_xray_sdk.core.models.segment

Module Contents

ORIGIN_TRACE_HEADER_ATTR_KEY = _origin_trace_header
class SegmentContextManager(recorder, name=None, **segment_kwargs)

Wrapper for segment and recorder to provide segment context manager.

__enter__(self)
__exit__(self, exc_type, exc_val, exc_tb)
class Segment(name, entityid=None, traceid=None, parent_id=None, sampled=True)

Bases:aws_xray_sdk.core.models.entity.Entity

The compute resources running your application logic send data about their work as segments. A segment provides the resource’s name, details about the request, and details about the work done.

add_subsegment(self, subsegment)

Add input subsegment as a child subsegment and increment reference counter and total subsegments counter.

increment(self)

Increment reference counter to track on open subsegments and total subsegments counter to track total size of subsegments it currently hold.

decrement_ref_counter(self)

Decrement reference counter by 1 when a subsegment is closed.

ready_to_send(self)

Return True if the segment doesn’t have any open subsegments and itself is not in progress.

get_total_subsegments_size(self)

Return the number of total subsegments regardless of open or closed.

decrement_subsegments_size(self)

Decrement total subsegments by 1. This usually happens when a subsegment is streamed out.

remove_subsegment(self, subsegment)

Remove the reference of input subsegment.

set_user(self, user)

set user of a segment. One segment can only have one user. User is indexed and can be later queried.

set_service(self, service_info)

Add python runtime and version info. This method should be only used by the recorder.

set_rule_name(self, rule_name)

Add the matched centralized sampling rule name if a segment is sampled because of that rule. This method should be only used by the recorder.

__getstate__(self)

Used by jsonpikle to remove unwanted fields.