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

Popular posts from this blog

TCPDF How to show/display Chinese Character?

How to fix fancy box/Easy Fancybox scroll not work in mobile

Wordpress Load balancing: 2 web servers 1 MySQL without any Cloud services