Skip to content

Commit 33edd8f

Browse files
authored
Revert/upgrade from upstream (#28)
* remove file * remove file * Revert "fix HttpClientAspect duplicated spans (#25)" This reverts commit dec05fd. * Revert "Updating from main package (#24)" This reverts commit 00890fa. * fix noop file * importing some classes and fix ident
1 parent dec05fd commit 33edd8f

40 files changed

+255
-1300
lines changed

class_map/GlobalTracer.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

class_map/Map.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* @contact [email protected]
1010
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
1111
*/
12-
1312
namespace Zipkin\Propagation;
1413

1514
use ArrayAccess;

composer.json

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,18 @@
1111
],
1212
"homepage": "https://hyperf.io",
1313
"support": {
14-
"issues": "https://github.com/hyperf/hyperf/issues",
15-
"source": "https://github.com/hyperf/hyperf",
1614
"docs": "https://hyperf.wiki",
17-
"pull-request": "https://github.com/hyperf/hyperf/pulls"
15+
"issues": "https://github.com/hyperf/hyperf/issues",
16+
"pull-request": "https://github.com/hyperf/hyperf/pulls",
17+
"source": "https://github.com/hyperf/hyperf"
1818
},
1919
"require": {
20-
"php": ">=8.1",
21-
"hyperf/collection": "~3.1.0",
22-
"hyperf/context": "~3.1.0",
23-
"hyperf/contract": "~3.1.0",
24-
"hyperf/coordinator": "~3.1.0",
25-
"hyperf/coroutine": "~3.1.0",
26-
"hyperf/di": "~3.1.0",
27-
"hyperf/engine": "^2.0",
28-
"hyperf/guzzle": "~3.1.0",
29-
"hyperf/stringable": "~3.1.0",
30-
"hyperf/support": "~3.1.0",
20+
"php": ">=8.0",
21+
"hyperf/contract": "^3.0",
22+
"hyperf/di": "^3.0",
23+
"hyperf/guzzle": "^3.0",
24+
"hyperf/support": "^3.0",
25+
"hyperf/utils": "^3.0",
3126
"jcchavezs/zipkin-opentracing": "^2.0",
3227
"jonahgeorge/jaeger-client-php": "^1.4",
3328
"opentracing/opentracing": "^1.0",
@@ -45,8 +40,7 @@
4540
},
4641
"suggest": {
4742
"hyperf/event": "Required to use DbQueryExecutedListener.",
48-
"jonahgeorge/jaeger-client-php": "Required (^0.6) to use jaeger tracing.",
49-
"longlang/phpkafka": "Required (^1.2) to use Kafka Producer."
43+
"jonahgeorge/jaeger-client-php": "Required (^0.6) to use jaeger tracing."
5044
},
5145
"autoload": {
5246
"psr-4": {
@@ -73,7 +67,7 @@
7367
},
7468
"extra": {
7569
"branch-alias": {
76-
"dev-master": "3.1-dev"
70+
"dev-master": "3.0-dev"
7771
},
7872
"hyperf": {
7973
"config": "Hyperf\\Tracer\\ConfigProvider"

publish/opentracing.php

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,20 @@
99
* @contact [email protected]
1010
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
1111
*/
12+
use Zipkin\Samplers\BinarySampler;
1213
use Hyperf\Tracer\Adapter\JaegerTracerFactory;
13-
use Hyperf\Tracer\Adapter\NoopTracerFactory;
14-
use Hyperf\Tracer\Adapter\Reporter\Kafka;
1514
use Hyperf\Tracer\Adapter\ZipkinTracerFactory;
16-
use Zipkin\Reporters\Http;
17-
use Zipkin\Reporters\Noop;
18-
use Zipkin\Samplers\BinarySampler;
1915

2016
use function Hyperf\Support\env;
2117

2218
return [
23-
// To disable hyperf/opentracing temporarily, set default driver to noop.
2419
'default' => env('TRACER_DRIVER', 'zipkin'),
2520
'enable' => [
26-
'coroutine' => env('TRACER_ENABLE_COROUTINE', false),
27-
'db' => env('TRACER_ENABLE_DB', false),
28-
'elasticserach' => env('TRACER_ENABLE_ELASTICSERACH', false),
29-
'exception' => env('TRACER_ENABLE_EXCEPTION', false),
30-
'grpc' => env('TRACER_ENABLE_GRPC', false),
3121
'guzzle' => env('TRACER_ENABLE_GUZZLE', false),
32-
'method' => env('TRACER_ENABLE_METHOD', false),
3322
'redis' => env('TRACER_ENABLE_REDIS', false),
34-
'rpc' => env('TRACER_ENABLE_RPC', false),
35-
'ignore_exceptions' => [],
23+
'db' => env('TRACER_ENABLE_DB', false),
24+
'method' => env('TRACER_ENABLE_METHOD', false),
25+
'exception' => env('TRACER_ENABLE_EXCEPTION', false),
3626
],
3727
'tracer' => [
3828
'zipkin' => [
@@ -44,34 +34,9 @@
4434
'ipv6' => null,
4535
'port' => 9501,
4636
],
47-
'reporter' => env('ZIPKIN_REPORTER', 'http'), // kafka, http
48-
'reporters' => [
49-
// options for http reporter
50-
'http' => [
51-
'class' => Http::class,
52-
'constructor' => [
53-
'options' => [
54-
'endpoint_url' => env('ZIPKIN_ENDPOINT_URL', 'http://localhost:9411/api/v2/spans'),
55-
'timeout' => env('ZIPKIN_TIMEOUT', 1),
56-
],
57-
],
58-
],
59-
// options for kafka reporter
60-
'kafka' => [
61-
'class' => Kafka::class,
62-
'constructor' => [
63-
'options' => [
64-
'topic' => env('ZIPKIN_KAFKA_TOPIC', 'zipkin'),
65-
'bootstrap_servers' => env('ZIPKIN_KAFKA_BOOTSTRAP_SERVERS', '127.0.0.1:9092'),
66-
'acks' => (int) env('ZIPKIN_KAFKA_ACKS', -1),
67-
'connect_timeout' => (int) env('ZIPKIN_KAFKA_CONNECT_TIMEOUT', 1),
68-
'send_timeout' => (int) env('ZIPKIN_KAFKA_SEND_TIMEOUT', 1),
69-
],
70-
],
71-
],
72-
'noop' => [
73-
'class' => Noop::class,
74-
],
37+
'options' => [
38+
'endpoint_url' => env('ZIPKIN_ENDPOINT_URL', 'http://localhost:9411/api/v2/spans'),
39+
'timeout' => env('ZIPKIN_TIMEOUT', 1),
7540
],
7641
'sampler' => BinarySampler::createAsAlwaysSample(),
7742
],
@@ -95,9 +60,6 @@
9560
],
9661
],
9762
],
98-
'noop' => [
99-
'driver' => NoopTracerFactory::class,
100-
],
10163
],
10264
'tags' => [
10365
'http_client' => [
@@ -122,21 +84,14 @@
12284
],
12385
'request' => [
12486
'path' => 'request.path',
125-
'uri' => 'request.uri',
12687
'method' => 'request.method',
12788
'header' => 'request.header',
128-
// 'body' => 'request.body',
12989
],
13090
'coroutine' => [
13191
'id' => 'coroutine.id',
13292
],
13393
'response' => [
13494
'status_code' => 'response.status_code',
135-
// 'body' => 'response.body',
136-
],
137-
'rpc' => [
138-
'path' => 'rpc.path',
139-
'status' => 'rpc.status',
14095
],
14196
],
14297
];

src/Adapter/HttpClientFactory.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,43 @@
99
* @contact [email protected]
1010
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
1111
*/
12-
1312
namespace Hyperf\Tracer\Adapter;
1413

15-
/**
16-
* @deprecated v3.0, will remove in v3.1, use \Hyperf\Tracer\Adapter\Reporter\HttpClientFactory instead.
17-
*/
18-
class HttpClientFactory extends Reporter\HttpClientFactory
14+
use Hyperf\Guzzle\ClientFactory as GuzzleClientFactory;
15+
use RuntimeException;
16+
use Zipkin\Reporters\Http\ClientFactory;
17+
18+
class HttpClientFactory implements ClientFactory
1919
{
20+
public function __construct(private GuzzleClientFactory $guzzleClientFactory)
21+
{
22+
}
23+
24+
public function build(array $options): callable
25+
{
26+
return function (string $payload) use ($options): void {
27+
$url = $options['endpoint_url'];
28+
unset($options['endpoint_url']);
29+
$client = $this->guzzleClientFactory->create($options);
30+
$additionalHeaders = $options['headers'] ?? [];
31+
$requiredHeaders = [
32+
'Content-Type' => 'application/json',
33+
'Content-Length' => strlen($payload),
34+
'b3' => '0',
35+
];
36+
$headers = array_merge($additionalHeaders, $requiredHeaders);
37+
$response = $client->post($url, [
38+
'body' => $payload,
39+
'headers' => $headers,
40+
// If 'no_aspect' option is true, then the HttpClientAspect will not modify the client options.
41+
'no_aspect' => true,
42+
]);
43+
$statusCode = $response->getStatusCode();
44+
if ($statusCode !== 202) {
45+
throw new RuntimeException(
46+
sprintf('Reporting of spans failed, status code %d', $statusCode)
47+
);
48+
}
49+
};
50+
}
2051
}

src/Adapter/NoOpTracerFactory.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Adapter/NoopTracerFactory.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
declare(strict_types=1);
44
/**
5-
* This file is part of Hyperf + OpenCodeCo
5+
* This file is part of Hyperf.
66
*
7-
* @link https://opencodeco.dev
7+
* @link https://www.hyperf.io
88
* @document https://hyperf.wiki
9-
* @contact [email protected]
10-
* @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
1111
*/
12-
1312
namespace Hyperf\Tracer\Adapter;
1413

1514
use Hyperf\Tracer\Contract\NamedFactoryInterface;

0 commit comments

Comments
 (0)