×ðÁú¿­Ê±¹ÙÍøµÇ¼

SwooleÒì³ÌÐòÊÔ¼¼ÇÉ£ºÊ¹ÓÃTideways¾ÙÐÐÐÔÄܼà²â

Ëæ×ÅswooleÔÚphpÉçÇøÖеÄÆÕ¼°Ë®Æ½Ô½À´Ô½¸ß£¬Ô½À´Ô½¶àµÄ¿ª·¢Õß×îÏÈÏíÊÜswooleËù´øÀ´µÄ׿ԽÐÔÄÜ¡¢¸ß¿ÉÀ©Õ¹ÐԺ͸»ºñµÄÒì²½±à³ÌÄÜÁ¦¡£È»¶ø£¬ÔÚʹÓÃswoole¾ÙÐпª·¢Ê±£¬ÎÒÃÇÄÑÃâ»áÓöµ½ÖÖÖÖ¸÷ÑùµÄÎÊÌ⣬ÆäÖÐ×î³£¼ûµÄÎÊÌâÖ®Ò»¾ÍÊÇÐÔÄÜÆ¿¾±¡£ÎªÏàʶ¾öÕâ¸öÎÊÌ⣬ÎÒÃÇÐèÒªÒ»ÖÖÓÐÓõÄÐÔÄܼà²â¹¤¾ßÀ´×ÊÖúÎÒÃÇÆÊÎöºÍÓÅ»¯´úÂëÐÔÄÜ¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃtidewaysÀ´¶ÔswooleÓ¦ÓþÙÐÐÐÔÄܼà²â£¬²¢ÌṩһЩÊÊÓõĵ÷ÊÔ¼¼ÇÉ£¬×ÊÖú¿ª·¢Õ߸üºÃµØʹÓÃtidewaysÀ´ÆÊÎöºÍÓÅ»¯×Ô¼ºµÄ´úÂë¡£

Ò»¡¢Ê²Ã´ÊÇTideways £¿

TidewaysÊÇÓÉÒ»¸öÃûΪTideways GmbHµÄµÂ¹ú¹«Ë¾¿ª·¢µÄÐÔÄܼà²â¹¤¾ß£¬ÆäÄ¿µÄÊÇΪPHPÓ¦ÓóÌÐòÌṩ¸ßЧµÄÐÔÄܼà²âºÍÎÊÌâÕï¶Ï¹¦Ð§¡£TidewaysʹÓÃÁËÒ»¸öµÍÇÖÈëµÄAgent»úÖÆ£¬Äܹ»ÔÚPHPÓ¦ÓóÌÐòÖÐʵʱ¡¢ÎÞ·ìµØ²¶»ñÓ¦ÓóÌÐòµÄÐÔÄÜÊý¾Ý£¬ÒÔ±ã¾ÙÐÐÆÊÎöºÍÓÅ»¯¡£

TidewaysÌṩÁËÒ»¸öÏÂÁîÐнçÃ湤¾ß£¬½Ð×öTideways CLI£¬¿ÉÒÔÓÃÀ´ÔËÐкÍÖÎÀíTideways Agent¡£ÔÚ×°ÖÃTideways CLIÖ®ºó£¬ÎÒÃǾͿÉÒÔͨ¹ýÖ´ÐÐÒÔÏÂÏÂÁîÀ´Æô¶¯Tideways Agent£º

$ tideways daemon start

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

Æô¶¯Tideways Agentºó£¬ÎÒÃǾͿÉÒÔʹÓÃTidewaysÀ´¾ÙÐÐÐÔÄܼà²âºÍÎÊÌâÕï¶ÏÁË¡£

¶þ¡¢ÔõÑùÔÚSwooleÓ¦ÓóÌÐòÖÐʹÓÃTideways £¿

ÒªÔÚSwooleÓ¦ÓóÌÐòÖÐʹÓÃTideways£¬ÎÒÃÇÐèҪͨ¹ýComposer×°ÖÃTideways PHPÀ©Õ¹ºÍTideways SwooleÀ©Õ¹¡£ÔÚ×°ÖÃÍê³Éºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ´úÂëÀ´Æô¶¯Tideways£º

<?php
// ¼ÓÔØTidewaysÀ©Õ¹
if (extension_loaded('tideways')) {
    // ƾ֤ÐèÒªÉèÖÃTidewaysµÄÉèÖÃ
    $config = [
        'api_key' => 'YOUR_API_KEY',
        'sample_rate' => 100,
        'transaction_name' => 'default'
    ];
    tideways_enable($config);
}

// ¼ÓÔØTideways SwooleÀ©Õ¹
if (extension_loaded('tideways_swoole')) {
    tideways_swoole_enable();
}

// ÔÚSwooleµÄ»Øµ÷º¯ÊýÖÐʹÓÃTideways
$http = new SwooleHttpServer("0.0.0.0", 9501);
$http->on('request', function ($request, $response) {
    // ʹÓÃTideways¿ªÆôÒ»¸öÊÂÎñ
    tideways_transaction_start();

    // ´¦ÀíÓªÒµÂß¼­
    handle_request($request, $response);

    // ʹÓÃTideways¿¢ÊÂÄ¿½ñÊÂÎñ
    tideways_transaction_end();
});

$http->start();

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇÊ×ÏÈÐèÒª¼ÓÔØTidewaysºÍTideways SwooleÀ©Õ¹¡£È»ºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃtideways_enable()º¯ÊýÀ´ÆôÓÃTideways£¬²¢Æ¾Ö¤ÐèÒªÉèÖÃһЩÉèÖá£ÔÚSwooleµÄ»Øµ÷º¯ÊýÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýŲÓÃtideways_transaction_start()º¯ÊýÀ´¿ªÆôÒ»¸öÐÂÊÂÎñ£¬ÔÙͨ¹ýŲÓÃtideways_transaction_end()º¯ÊýÀ´¿¢ÊÂÄ¿½ñÊÂÎñ¡£ÕâÑù£¬ÎÒÃǾͿÉÒÔʹÓÃTidewaysÀ´¼à²âSwooleÓ¦ÓóÌÐòÖеÄÐÔÄÜÊý¾ÝÁË¡£

Èý¡¢Ê¹ÓÃTideways¾ÙÐÐÐÔÄܼà²âºÍÆÊÎöµÄ¼¼ÇÉ

ÆôÓÃTidewaysÖ®ºó£¬ÎÒÃǾͿÉÒÔ½èÖúTidewaysÌṩµÄÖÖÖÖ¹¦Ð§£¬¶ÔSwooleÓ¦ÓóÌÐòµÄÐÔÄܾÙÐмà²âºÍÆÊÎöÁË£¬ÏÂÃæÏÈÈÝһЩÊÊÓõļ¼ÇÉ¡£

1. É趨ÊÂÎñÃû³ÆºÍ²ÉÑùÂÊ

ÔÚ¿ª·¢SwooleÓ¦ÓóÌÐòʱ£¬ÎªÁ˸üºÃµØÆÊÎöÐÔÄÜÊý¾Ý£¬ÎÒÃÇÐèҪΪÿ¸öÊÂÎñÖ¸¶¨Ò»¸öÓÐÒâÒåµÄÃû³Æ£¬²¢ÉèÖÃÒ»¸öºÏÊʵIJÉÑùÂÊ¡£ÊÂÎñÃû³ÆÓ¦¸Ã¾¡¿ÉÄܵØ׼ȷÐÎòĿ½ñÊÂÎñ´¦ÀíµÄÂß¼­£¬ÒÔ±ãÔÚºóÐøµÄÊý¾ÝÆÊÎöÖиüºÃµØʶ±ðºÍÇø·Ö¸÷¸öÊÂÎñ¡£²ÉÑùÂÊÊÇÒ»¸ö¿ØÖÆÊý¾ÝÍøÂçÁ¿ºÍ²ÉÑù¾«¶ÈµÄ²ÎÊý£¬Æ¾Ö¤ÏÖÕæÏàÐξÙÐе÷Àí¼´¿É¡£

<?php
// ƾ֤ÏÖÕæÏàÐÎÉ趨ÊÂÎñÃû³ÆºÍ²ÉÑùÂÊ£¬²¢´«Èë$configÊý×éÖÐ
$config = [
    'transaction_name' => 'my_transaction_name',
    'sample_rate' => 50
];
tideways_enable($config);

µÇ¼ºó¸´ÖÆ

2. ʹÓÃXHProf Profiler¾ÙÐдúÂëÆÊÎö

TidewaysÖ§³ÖʹÓÃXHProf Profiler¾ÙÐдúÂëÆÊÎö¡£Í¨¹ýÆôÓÃXHProf Profiler£¬ÎÒÃÇ¿ÉÒÔÏàʶÿ¸öÊÂÎñÖÐÄÄЩº¯Êý¡¢ÒªÁìÖ´ÐÐʱ¼ä×£¬ÄÄЩ²¿·ÖµÄÐÔÄÜÐèÒª½øÒ»²½ÓÅ»¯¡£

ÔÚʹÓÃXHProf Profilerʱ£¬ÎÒÃÇÐèÒªÖ´ÐÐÒÔϲÙ×÷£º

ÆôÓÃXHProf£º

tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_CPU | TIDEWAYS_XHPROF_FLAGS_MEMORY);

µÇ¼ºó¸´ÖÆ

¾ÙÐÐÐÔÄÜÆÊÎö²¢×èÖ¹XHProf£º

$result = tideways_xhprof_disable();

µÇ¼ºó¸´ÖÆ

´òÓ¡ÐÔÄÜÊý¾Ý£º

print_r($result);

µÇ¼ºó¸´ÖÆ

ÏêϸµÄʵÏÖ¿ÉÒԲο¼ÒÔÏ´úÂ룺

<?php
// ÆôÓÃXHProf Profiler
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_CPU | TIDEWAYS_XHPROF_FLAGS_MEMORY);

// Ö´ÐÐһЩӪҵÂß¼­
do_some_stuff();

// ×èÖ¹XHProf Profiler²¢»ñÈ¡ÐÔÄÜÊý¾Ý
$xhprof_data = tideways_xhprof_disable();

// ´òÓ¡ÐÔÄÜÊý¾Ý
print_r($xhprof_data);

µÇ¼ºó¸´ÖÆ

ÔÚ³ÌÐòÔËÐÐÍê³Éºó£¬ÎÒÃÇ¿ÉÒÔÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁîÀ´Éó²éÐÔÄÜÊý¾Ý£º

$ php -r "print_r(unserialize(file_get_contents('xhprof-data.xhprof')))"

Array
(
    [data] => Array
        (
            [my_program/1604976975.944807] => Array
                (
                    [wt] => 1604976962
                    [cpu] => 1215860
                    [mu] => 11700
                    [pmu] => 1604568
                    [samples] => Array
                        (
                            [main()] => Array
                                (
                                    [wt] => 1604976962
                                    [cpu] => 1215860
                                    [mu] => 11700
                                    [pmu] => 1604568
                                    [n] => 1
                                    [wt.1] => 1604976962
                                    [cpu.1] => 1215860
                                    [mu.1] => 11700
                                    [pmu.1] => 1604568
                                    [is_main] => 1
                                )
                            [my_function()] => Array
                                (
                                    [wt] => 10
                                    [cpu] => 10
                                    [mu] => 0
                                    [pmu] => 0
                                    [n] => 1
                                    [wt.1] => 10
                                    [cpu.1] => 10
                                    [mu.1] => 0
                                    [pmu.1] => 0
                                )
                        )
                )
        )
)

µÇ¼ºó¸´ÖÆ

3. ʹÓÃTideways Traces¾ÙÐÐʵʱÆÊÎö

Tideways TracesÊÇÒ»¸öʵʱµÄÐÔÄܼà²âºÍÆÊÎö¹¤¾ß£¬ÔÚSwooleÓ¦ÓóÌÐòÖеÄʹÓúÜÊÇÀû±ã¡£Í¨¹ýTideways Traces£¬ÎÒÃÇ¿ÉÒÔʵʱÉó²é¸÷¸öÊÂÎñµÄ´¦Àíʱ¼ä¡¢×ÊÔ´ÏûºÄÇéÐεÈÐÅÏ¢£¬ÒÔ×ÊÖúÎÒÃÇ¿ìËÙʶ±ðÐÔÄÜÆ¿¾±ºÍÎÊÌâ¡£

ʹÓÃTideways Traces¾ÙÐÐʵʱÆÊÎöµÄÏêϸ°ì·¨ÈçÏ£º

Æô¶¯Tideways Agent£º

$ tideways daemon start

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÆôÓÃTideways£º

$config = [
    'api_key' => 'YOUR_API_KEY'
];
tideways_enable($config);

µÇ¼ºó¸´ÖÆ

ÆôÓÃTideways Traces£º

tideways_enable_tracing();

µÇ¼ºó¸´ÖÆ

ÆôÓÃTideways Tracesºó£¬ÎÒÃǾͿÉÒÔÔÚTideways DashboardÖÐʵʱÉó²é¸÷¸öÊÂÎñµÄ´¦ÀíÇéÐÎÁË¡£ÏêϸµÄʹÓÃÒªÁì¿ÉÒԲο¼TidewaysµÄ¹Ù·½Îĵµ¡£

ËÄ¡¢×ܽá

ʹÓÃTideways¾ÙÐÐÐÔÄܼà²âºÍÆÊÎöÊÇÒ»ÏîºÜÊÇÊÊÓõÄÊÖÒÕ£¬ÔÚSwooleÓ¦ÓóÌÐò¿ª·¢ÖÐÓÈΪÖ÷Òª¡£Í¨¹ý±¾ÎÄÏÈÈݵÄÒªÁ죬ÎÒÃÇ¿ÉÒÔÇáËɵØÆôÓÃTideways£¬²¢Ê¹ÓÃÆäÌṩµÄÖÖÖÖ¹¦Ð§¶ÔSwooleÓ¦ÓóÌÐò¾ÙÐÐÐÔÄÜÆÊÎö£¬ÒÔ±ã¸üºÃµØÓÅ»¯ºÍË¢ÐÂÓ¦ÓóÌÐò¡£ËäÈ»£¬TidewaysÖ»ÊÇÖÚ¶àÐÔÄܼà²â¹¤¾ßÖеÄÒ»ÖÖ£¬ÎÒÃÇ»¹¿ÉÒÔƾ֤ÏÖÕæÏàÐÎÑ¡ÔñÆäËûºÏÊʵŤ¾ß¾ÙÐÐÐÔÄܼà²âºÍÆÊÎö¡£

ÒÔÉϾÍÊÇSwooleÒì³ÌÐòÊÔ¼¼ÇÉ£ºÊ¹ÓÃTideways¾ÙÐÐÐÔÄܼà²âµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ