AWS XRay PHP generate trace_id and id
Code below to generate `trace_id` and `id` that are required in `putTraceSegments()` function if you are using AWS XRay:
Example:
$trace_id = sprintf( '%s-%s-%s', '1', dechex( (int)time() ), bin2hex( openssl_random_pseudo_bytes(12)) );
);
$trace_seg = array(
'id' => bin2hex(openssl_random_pseudo_bytes(16)),
'name' => 'TestName_'.date("YmdHis"),
'trace_id' => $trace_id,
'start_time' => microtime(true),
'end_time ' => date("U", strtotime('now + 10 seconds') )
// 'in_progress' => true,
Reference: AWS putTraceSegments() documentation
Comments