-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contributors: @cHeeSaW
- Loading branch information
Showing
8 changed files
with
177 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
# auxmoney OpentracingBundle - Zipkin | ||
|
||
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/auxmoney/OpentracingBundle-Zipkin) | ||
![Travis (.org)](https://img.shields.io/travis/auxmoney/OpentracingBundle-Zipkin) | ||
![Coveralls github](https://img.shields.io/coveralls/github/auxmoney/OpentracingBundle-Zipkin) | ||
![Codacy Badge](https://api.codacy.com/project/badge/Grade/626c5a0a955b4318bb9a4f82bd2ee7a2) | ||
![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/auxmoney/OpentracingBundle-Zipkin) | ||
![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/auxmoney/OpentracingBundle-Zipkin) | ||
![GitHub](https://img.shields.io/github/license/auxmoney/OpentracingBundle-Zipkin) | ||
|
||
This symfony bundle provides a tracer implementation for [Zipkin](https://zipkin.io/) for the [auxmoney OpentracingBundle](https://github.com/auxmoney/OpentracingBundle-core). | ||
|
||
Please have a look at [the central documentation](https://github.com/auxmoney/OpentracingBundle-core) for installation and usage instructions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Auxmoney\OpentracingBundle\Tests\Functional; | ||
|
||
use GuzzleHttp\Client; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\Process\Process; | ||
|
||
class FunctionalTest extends TestCase | ||
{ | ||
public function testSuccessfulTracing(): void | ||
{ | ||
$this->setupTestProject(); | ||
|
||
$p = new Process(['symfony', 'console', 'test:zipkin'], 'build/testproject'); | ||
$p->mustRun(); | ||
$traceId = trim($p->getOutput()); | ||
self::assertNotEmpty($traceId); | ||
|
||
$spans = $this->getTraceFromZipkinAPI($traceId); | ||
self::assertCount(1, $spans); | ||
self::assertSame('test:zipkin', $spans[0]['name']); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$p = new Process(['docker', 'start', 'zipkin']); | ||
$p->mustRun(); | ||
|
||
sleep(10); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$p = new Process(['git', 'reset', '--hard', 'reset'], 'build/testproject'); | ||
$p->mustRun(); | ||
$p = new Process(['docker', 'stop', 'zipkin']); | ||
$p->mustRun(); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
private function getTraceFromZipkinAPI(string $traceId): array | ||
{ | ||
$client = new Client(); | ||
$response = $client->get(sprintf('http://localhost:9411/zipkin/api/v2/trace/%s', $traceId)); | ||
return json_decode($response->getBody()->getContents(), true); | ||
} | ||
|
||
private function setupTestProject(): void | ||
{ | ||
$filesystem = new Filesystem(); | ||
$filesystem->mirror(sprintf('Tests/Functional/TestProjectFiles/default/'), 'build/testproject/'); | ||
|
||
$p = new Process(['composer', 'dump-autoload'], 'build/testproject'); | ||
$p->mustRun(); | ||
$p = new Process(['symfony', 'console', 'cache:clear'], 'build/testproject'); | ||
$p->mustRun(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker rm zipkin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
cd build/testproject/ | ||
composer remove auxmoney/opentracing-bundle-jaeger | ||
composer require auxmoney/opentracing-bundle-zipkin:dev-${BRANCH} | ||
cd ../../ | ||
|
||
docker run -d -p 9411:9411 --name zipkin openzipkin/zipkin:2.19 | ||
sleep 5 | ||
docker stop zipkin |
31 changes: 31 additions & 0 deletions
31
Tests/Functional/TestProjectFiles/default/src/Command/TestCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Command; | ||
|
||
use Auxmoney\OpentracingBundle\Internal\Opentracing; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use const OpenTracing\Formats\TEXT_MAP; | ||
|
||
class TestCommand extends Command | ||
{ | ||
private $opentracing; | ||
|
||
public function __construct(Opentracing $opentracing) | ||
{ | ||
parent::__construct('test:zipkin'); | ||
$this->setDescription('some fancy command description'); | ||
$this->opentracing = $opentracing; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$carrier = []; | ||
$this->opentracing->getTracerInstance()->inject($this->opentracing->getTracerInstance()->getActiveSpan()->getContext(), TEXT_MAP, $carrier); | ||
$output->writeln(current($carrier)); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters