Ejemplo n.º 1
0
function echo_api_durations()
{
    if (get_request_param('purgedata', 'false') === 'true') {
        $GLOBALS['m3client']->metricsPurgeApiDurations();
    }
    echo <<<EOF
    <form action="metrics.php?show=apidurations" method="get">
       <input type="submit" value="Clear Data" />
       <input type="hidden" name="show" value="apidurations" />
       <input type="hidden" name="purgedata" value="true" />
    </form>
EOF;
    // $_metrics[API] = array("count", "min", "max", "avg")
    $_metrics = $GLOBALS['m3client']->metricsGetApiDurations();
    echo <<<EOF
    <table border="1">
    <tr>
        <th>API</td>
        <th>Invocation Count</th>
        <th>Min Time(ms)</th>
        <th>Max Time(ms)</th>
        <th>Average Time(ms)</th>
    </tr>
EOF;
    foreach ($_metrics as $_apiName => $_stats) {
        $_count = $_stats['count'];
        $_min = sprintf("%5.2f", 1000 * $_stats['min']);
        $_max = sprintf("%5.2f", 1000 * $_stats['max']);
        $_avg = sprintf("%5.2f", 1000 * $_stats['avg']);
        echo <<<EOF2
    <tr>
        <td>{$_apiName}</td>
        <td>{$_count}</td>
        <td>{$_min}</td>
        <td>{$_max}</td>
        <td>{$_avg}</td>
    </tr>
EOF2;
    }
    echo "</table>\n";
    echo_api_visualization($_metrics);
}
Ejemplo n.º 2
0
<?php

$_metrics = $this->m3->metricsGetApiDurations();
echo_api_visualization($_metrics);
function echo_api_visualization($metrics)
{
    if (!isset($metrics) || empty($metrics)) {
        return;
    }
    $_totalApis = count($metrics);
    echo <<<EOF

   <div id="count_div"></div>
   <hr/>
   <div id="avg_div"></div>
   <hr/>
   <div id="rt_div"></div>

<script type="text/javascript">
        //google.setOnLoadCallback(drawVisualization); // Set callback to run when API is loaded
        function drawVisualization()
        {
            var dataCallCount = new google.visualization.DataTable();
            dataCallCount.addColumn('string', 'API');
            dataCallCount.addColumn('number', 'Invocation Count');
            dataCallCount.addRows({$_totalApis});

            var dataAverage = new google.visualization.DataTable();
            dataAverage.addColumn('string', 'API');
            dataAverage.addColumn('number', 'Average Response Time(ms)');
            dataAverage.addRows({$_totalApis});