def send_subsegment_to_xray_daemon(subsegment_id, parent_id,
                                   start_time, end_time=None, name=None,
                                   namespace='remote', extra_data=None):
    """High level function to send data to the X-Ray Daemon.

    If `end_time` is set to `None` (which is the default), a partial subsegment
    will be sent to X-Ray, which has to be completed by a subsequent call to
    this function after the underlying operation finishes.

    The `namespace` argument can either be `aws` or `remote` (`local` is used
    as a default, but  it's not officially supported by X-Ray).

    The `extra_data` argument must be a `dict` that is used for updating the
    segment document with arbitrary data.
    """
    extra_data = extra_data or {}
    trace_id = get_trace_id()
    segment_document = {
        'type': 'subsegment',
        'id': subsegment_id,
        'trace_id': trace_id.trace_id,
        'parent_id': parent_id,
        'start_time': start_time,
    }
    if end_time is None:
        segment_document['in_progress'] = True
    else:
        segment_document.update({
            'end_time': end_time,
            'name': name,
            'namespace': namespace,
        })
        segment_document.update(extra_data)

    LOGGER.debug(
        'Prepared segment document for X-Ray Daemon',
        segment_document=segment_document,
    )
    send_segment_document_to_xray_daemon(segment_document)
def send_subsegment_to_xray_daemon ( subsegment_id , parent_id , start_time , end_time = None , name = None , namespace = 'remote' , extra_data = None ) : extra_data = extra_data or { } trace_id = get_trace_id ( ) segment_document = { 'type' : 'subsegment' , 'id' : subsegment_id , 'trace_id' : trace_id . trace_id , 'parent_id' : parent_id , 'start_time' : start_time , } if end_time is None : segment_document [ 'in_progress' ] = True else : segment_document . update ( { 'end_time' : end_time , 'name' : name , 'namespace' : namespace , } ) segment_document . update ( extra_data ) LOGGER . debug ( 'Prepared segment document for X-Ray Daemon' , segment_document = segment_document , ) send_segment_document_to_xray_daemon ( segment_document )
High level function to send data to the X-Ray Daemon.

    If `end_time` is set to `None` (which is the default), a partial subsegment
    will be sent to X-Ray, which has to be completed by a subsequent call to
    this function after the underlying operation finishes.

    The `namespace` argument can either be `aws` or `remote` (`local` is used
    as a default, but  it's not officially supported by X-Ray).

    The `extra_data` argument must be a `dict` that is used for updating the
    segment document with arbitrary data.