Пример #1
0
 public function testSpanMaxRecords()
 {
     $runtime = Traceguide::newRuntime("test_group", "1234567890");
     $maxRecords = peek($runtime, "_options")["max_span_records"];
     // Sanity check that the default is not abnormally small (or more
     // likely that the internal variable named hasn't been changed and
     // invalidated this test!)
     $this->assertGreaterThan(10, $maxRecords);
     // Before the max is hit...
     for ($i = 0; $i < $maxRecords; $i++) {
         $span = $runtime->startSpan();
         $span->setOperation("loop_span");
         $span->finish();
         $this->assertEquals($i + 1, count(peek($runtime, "_spanRecords")));
     }
     // After the max has been hit...
     for ($i = 0; $i < 10 * $maxRecords; $i++) {
         $span = $runtime->startSpan();
         $span->setOperation("loop_span");
         $span->finish();
         $this->assertEquals($maxRecords, count(peek($runtime, "_spanRecords")));
     }
     $runtime->_discard();
     $this->assertEquals(0, count(peek($runtime, "_spanRecords")));
 }
Пример #2
0
function _next()
{
    global $theA, $theB, $EOF;
    $c = get();
    if ($c == ord("/")) {
        switch (peek()) {
            case ord("/"):
                for (;;) {
                    $c = get();
                    if ($c <= ord("\n")) {
                        return $c;
                    }
                }
            case ord("*"):
                get();
                for (;;) {
                    switch (get()) {
                        case ord("*"):
                            if (peek() == ord("/")) {
                                get();
                                return ord(" ");
                            }
                            break;
                        case $EOF:
                            printf("Error: JSMIN Unterminated comment.\n");
                            exit(1);
                    }
                }
            default:
                return $c;
        }
    }
    return $c;
}
Пример #3
0
 public function testSpanAttributes()
 {
     $runtime = Traceguide::newRuntime("test_group", "1234567890");
     $span = $runtime->startSpan();
     $span->addAttribute("test_attribute_1", "value 1");
     $span->addAttribute("test_attribute_2", "value 2");
     $this->assertEquals(count(peek($span, "_attributes")), 2);
     $span->addAttribute("test_attribute_3", "value 3");
     $this->assertEquals(count(peek($span, "_attributes")), 3);
     $span->finish();
 }
Пример #4
0
 public function testSpanBufferingBeforeInit()
 {
     $runtime = Traceguide::newRuntime(NULL, NULL);
     $span = $runtime->startSpan();
     $span->setOperation("first");
     $span->infof('Hello %s', 'World');
     $span->finish();
     $runtime->options(array('group_name' => 'init_test_group', 'access_token' => '1234567890'));
     $span = $runtime->startSpan();
     $span->setOperation("second");
     $span->infof('Hola %s', 'Mundo');
     $span->finish();
     $this->assertEquals(2, count(peek($runtime, "_spanRecords")));
     $runtime->flush();
 }