public function testDisable() { $runtime = LightStep::newTracer("test_group", "1234567890"); $runtime->disable(); $span = $runtime->startSpan("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(); }
public function testDeeplyNested() { $runtime = LightStep::newTracer("test_group", "1234567890"); $span = $runtime->startSpan('test_span'); $span->infof("test", $this->_wrapValue("value!", 2)); $span->infof("test", $this->_wrapValue("value!", 4)); $span->infof("test", $this->_wrapValue("value!", 8)); $span->infof("test", $this->_wrapValue("value!", 10)); $span->infof("test", $this->_wrapValue("value!", 100)); $span->infof("test", $this->_wrapValue("value!", 1000)); $span->finish(); }
public function testSpanBufferingBeforeInit() { $runtime = LightStep::newTracer(NULL, NULL); $span = $runtime->startSpan("first"); $span->infof('Hello %s', 'World'); $span->finish(); $runtime->options(array('component_name' => 'init_test_group', 'access_token' => '1234567890')); $span = $runtime->startSpan("second"); $span->infof('Hola %s', 'Mundo'); $span->finish(); $this->assertEquals(2, count($this->peek($runtime, "_spanRecords"))); $runtime->flush(); }
public function testSpanMaxRecords() { $runtime = LightStep::newTracer("test_group", "1234567890", array('debug_disable_flush' => TRUE)); $maxRecords = $this->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("loop_span"); $span->finish(); $this->assertEquals($i + 1, count($this->peek($runtime, "_spanRecords"))); } $this->assertEquals($maxRecords, count($this->peek($runtime, "_spanRecords"))); // After the max has been hit... for ($i = 0; $i < 10 * $maxRecords; $i++) { $span = $runtime->startSpan("loop_span"); $span->finish(); $this->assertEquals($maxRecords, count($this->peek($runtime, "_spanRecords"))); } $runtime->_discard(); $this->assertEquals(0, count($this->peek($runtime, "_spanRecords"))); }
public function testInjectJoin() { $tracer = LightStep::newTracer("test_group", "1234567890"); $span = $tracer->startSpan("hello/world"); $carrier = array(); $tracer->inject($span, LIGHTSTEP_FORMAT_TEXT_MAP, $carrier); $this->assertEquals($carrier['ot-tracer-spanid'], $span->guid()); $this->assertEquals($carrier['ot-tracer-traceid'], $span->traceGUID()); $this->assertEquals($carrier['ot-tracer-sampled'], 'true'); $span->finish(); $child = $tracer->join('child', LIGHTSTEP_FORMAT_TEXT_MAP, $carrier); $this->assertEquals($child->traceGUID(), $span->traceGUID()); $this->assertEquals($child->getParentGUID(), $span->guid()); $child->finish(); }