Exemple #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")));
 }
Exemple #2
0
 public function testDeeplyNested()
 {
     $runtime = Traceguide::newRuntime("test_group", "1234567890");
     $runtime->infof("test", $this->_wrapValue("value!", 2));
     $runtime->infof("test", $this->_wrapValue("value!", 4));
     $runtime->infof("test", $this->_wrapValue("value!", 8));
     $runtime->infof("test", $this->_wrapValue("value!", 10));
     $runtime->infof("test", $this->_wrapValue("value!", 100));
     $runtime->infof("test", $this->_wrapValue("value!", 1000));
 }
 public function testMultipleInitCalls()
 {
     $runtime = Traceguide::newRuntime(NULL, NULL);
     for ($i = 0; $i < 100; $i++) {
         $runtime->infof("log%03d", 3 * $i);
         // Redundant calls are fine as long as the configuration
         // is the same
         $runtime->options(array('group_name' => 'init_test_group', 'access_token' => '1234567890'));
         $runtime->infof("log%03d", 7 * $i);
     }
 }
 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();
 }
Exemple #5
0
 public function testSpanThriftRecord()
 {
     $runtime = Traceguide::newRuntime("test_group", "1234567890");
     $span = $runtime->startSpan();
     $span->setOperation("hello/world");
     $span->setEnduserId("dinosaur_sr");
     $span->finish();
     // Transform the object into a associative array
     $arr = json_decode(json_encode($span->toThrift()), TRUE);
     $this->assertTrue(is_string($arr["span_guid"]));
     $this->assertTrue(is_string($arr["runtime_guid"]));
     $this->assertTrue(is_string($arr["span_name"]));
     $this->assertEquals(1, count($arr["join_ids"]));
     $this->assertTrue(is_string($arr["join_ids"][0]["TraceKey"]));
     $this->assertTrue(is_string($arr["join_ids"][0]["Value"]));
 }
 public function testDisable()
 {
     $runtime = Traceguide::newRuntime("test_group", "1234567890");
     $runtime->disable();
     $runtime->infof("Shouldn't do anything");
     $runtime->warnf("Shouldn't do anything");
     $runtime->errorf("Shouldn't do anything");
     $runtime->fatalf("Shouldn't do anything");
     $span = $runtime->startSpan();
     $span->setOperation("noop_call");
     $span->setEndUserId("ignored_user");
     $span->addTraceJoinId("key_to_an", "unused_value");
     $span->warnf("Shouldn't do anything");
     $span->errorf("Shouldn't do anything");
     $span->finish();
 }