Skip to content

Commit

Permalink
opentracing/opentracing#1.0.0-beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgeorge committed Dec 5, 2017
1 parent 6153ac3 commit ad119f2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": ">=7.0",
"packaged/thrift": "0.10.0",
"opentracing/opentracing" : "dev-master#88ad53393dd3dff3c1d9698f72ec42a907eb4054",
"opentracing/opentracing" : "1.0.0-beta2",
"monolog/monolog": "^1.0"
},
"require-dev": {
Expand Down
19 changes: 13 additions & 6 deletions src/Jaeger/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use OpenTracing;
use const OpenTracing\Ext\Tags\SPAN_KIND;
use const OpenTracing\Ext\Tags\SPAN_KIND_RPC_SERVER;
use const OpenTracing\Propagation\Formats\BINARY;
use const OpenTracing\Propagation\Formats\HTTP_HEADERS;
use const OpenTracing\Propagation\Formats\TEXT_MAP;
use const OpenTracing\Formats\BINARY;
use const OpenTracing\Formats\HTTP_HEADERS;
use const OpenTracing\Formats\TEXT_MAP;
use OpenTracing\Propagation\Reader;
use OpenTracing\Propagation\Writer;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -107,6 +107,13 @@ public function __construct(
}
}

public function setSampler(SamplerInterface $sampler)
{
$this->sampler = $sampler;

return $this;
}

public function getServiceName(): string
{
return $this->serviceName;
Expand Down Expand Up @@ -141,7 +148,7 @@ public function startSpan($operationName, $options = [])
$parent = $parent->getContext();
}

$rpcServer = ($tags !== null) &&
$rpcServer = ($tags !== null) &&
($tags[SPAN_KIND] ?? null) == SPAN_KIND_RPC_SERVER;

if ($parent === null || $parent->isDebugIdContainerOnly()) {
Expand Down Expand Up @@ -210,7 +217,7 @@ public function startSpan($operationName, $options = [])
* @throws UnsupportedFormat when the format is not recognized by the tracer
* implementation
*/
public function inject(OpenTracing\SpanContext $spanContext, $format, Writer $carrier)
public function inject(OpenTracing\SpanContext $spanContext, $format, &$carrier)
{
$codec = $this->codecs[$format] ?? null;
if ($codec === null) {
Expand All @@ -228,7 +235,7 @@ public function inject(OpenTracing\SpanContext $spanContext, $format, Writer $ca
* @throws UnsupportedFormat when the format is not recognized by the tracer
* implementation
*/
public function extract($format, Reader $carrier)
public function extract($format, $carrier)
{
$codec = $this->codecs[$format] ?? null;
if ($codec === null) {
Expand Down
5 changes: 3 additions & 2 deletions tests/ReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Jaeger\Reporter\NullReporter;
use Jaeger\Span;
use \PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

class ReporterTest extends TestCase
{
Expand All @@ -32,12 +32,13 @@ public function testInMemoryReporter()

public function testLoggingReporter()
{
$logger = $this->createMock(LoggerInterface::class);
$logger = $this->createMock(NullLogger::class);
$span = $this->createMock(Span::class);
$reporter = new LoggingReporter($logger);

$logger->method('info')
->with($this->stringStartsWith('Reporting span'));

$reporter->reportSpan($span);
}
}
17 changes: 17 additions & 0 deletions tests/SpanContextTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Jaeger\SpanContext;
use PHPUnit\Framework\TestCase;

class SpanContextTest extends TestCase
{
public function test_is_debug_id_container_only()
{
$ctx = SpanContext::withDebugId('value1');
$this->assertTrue($ctx->isDebugIdContainerOnly());
$this->assertEquals($ctx->getDebugId(), 'value1');

$ctx = new SpanContext(1, 2, 3, 1);
$this->assertFalse($ctx->isDebugIdContainerOnly());
}
}

0 comments on commit ad119f2

Please sign in to comment.