|
9 | 9 | |
10 | 10 | * @license https://github.com/opencodeco/hyperf-metric/blob/main/LICENSE |
11 | 11 | */ |
| 12 | +use Hyperf\Tracer\Adapter\JaegerTracerFactory; |
| 13 | +use Hyperf\Tracer\Adapter\NoopTracerFactory; |
| 14 | +use Hyperf\Tracer\Adapter\Reporter\Kafka; |
| 15 | +use Hyperf\Tracer\Adapter\ZipkinTracerFactory; |
| 16 | +use Zipkin\Reporters\Http; |
| 17 | +use Zipkin\Reporters\Noop; |
12 | 18 | use Zipkin\Samplers\BinarySampler; |
13 | 19 |
|
14 | 20 | use function Hyperf\Support\env; |
15 | 21 |
|
16 | 22 | return [ |
| 23 | + // To disable hyperf/opentracing temporarily, set default driver to noop. |
17 | 24 | 'default' => env('TRACER_DRIVER', 'zipkin'), |
18 | 25 | 'enable' => [ |
19 | | - 'guzzle' => env('TRACER_ENABLE_GUZZLE', false), |
20 | | - 'redis' => env('TRACER_ENABLE_REDIS', false), |
| 26 | + 'coroutine' => env('TRACER_ENABLE_COROUTINE', false), |
21 | 27 | 'db' => env('TRACER_ENABLE_DB', false), |
22 | | - 'method' => env('TRACER_ENABLE_METHOD', false), |
| 28 | + 'elasticserach' => env('TRACER_ENABLE_ELASTICSERACH', false), |
23 | 29 | 'exception' => env('TRACER_ENABLE_EXCEPTION', false), |
| 30 | + 'grpc' => env('TRACER_ENABLE_GRPC', false), |
| 31 | + 'guzzle' => env('TRACER_ENABLE_GUZZLE', false), |
| 32 | + 'method' => env('TRACER_ENABLE_METHOD', false), |
| 33 | + 'redis' => env('TRACER_ENABLE_REDIS', false), |
| 34 | + 'rpc' => env('TRACER_ENABLE_RPC', false), |
| 35 | + 'ignore_exceptions' => [], |
24 | 36 | ], |
25 | 37 | 'tracer' => [ |
26 | 38 | 'zipkin' => [ |
27 | | - 'driver' => Hyperf\Tracer\Adapter\ZipkinTracerFactory::class, |
| 39 | + 'driver' => ZipkinTracerFactory::class, |
28 | 40 | 'app' => [ |
29 | 41 | 'name' => env('APP_NAME', 'skeleton'), |
30 | 42 | // Hyperf will detect the system info automatically as the value if ipv4, ipv6, port is null |
31 | 43 | 'ipv4' => '127.0.0.1', |
32 | 44 | 'ipv6' => null, |
33 | 45 | 'port' => 9501, |
34 | 46 | ], |
35 | | - 'options' => [ |
36 | | - 'endpoint_url' => env('ZIPKIN_ENDPOINT_URL', 'http://localhost:9411/api/v2/spans'), |
37 | | - 'timeout' => env('ZIPKIN_TIMEOUT', 1), |
| 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 | + ], |
38 | 75 | ], |
39 | 76 | 'sampler' => BinarySampler::createAsAlwaysSample(), |
40 | 77 | ], |
41 | 78 | 'jaeger' => [ |
42 | | - 'driver' => Hyperf\Tracer\Adapter\JaegerTracerFactory::class, |
| 79 | + 'driver' => JaegerTracerFactory::class, |
43 | 80 | 'name' => env('APP_NAME', 'skeleton'), |
44 | 81 | 'options' => [ |
45 | 82 | /* |
|
58 | 95 | ], |
59 | 96 | ], |
60 | 97 | ], |
| 98 | + 'noop' => [ |
| 99 | + 'driver' => NoopTracerFactory::class, |
| 100 | + ], |
61 | 101 | ], |
62 | 102 | 'tags' => [ |
63 | 103 | 'http_client' => [ |
|
82 | 122 | ], |
83 | 123 | 'request' => [ |
84 | 124 | 'path' => 'request.path', |
| 125 | + 'uri' => 'request.uri', |
85 | 126 | 'method' => 'request.method', |
86 | 127 | 'header' => 'request.header', |
| 128 | + // 'body' => 'request.body', |
87 | 129 | ], |
88 | 130 | 'coroutine' => [ |
89 | 131 | 'id' => 'coroutine.id', |
90 | 132 | ], |
91 | 133 | 'response' => [ |
92 | 134 | 'status_code' => 'response.status_code', |
| 135 | + // 'body' => 'response.body', |
| 136 | + ], |
| 137 | + 'rpc' => [ |
| 138 | + 'path' => 'rpc.path', |
| 139 | + 'status' => 'rpc.status', |
93 | 140 | ], |
94 | 141 | ], |
95 | 142 | ]; |
0 commit comments