0
PHP 使用 Zipkin 做调用链性能分析
先安装zipkin, 然后直接运行
docker pull openzipkin/zipkin
docker run -d -p 9411:9411 openzipkin/zipkin
$ composer require whitemerry/phpkin
运行下面的例子即可
<?php
namespace whitemerry\phpkin;
include './vendor/autoload.php';
$endpoint = new Endpoint(
'Passport', // Application name
'127.0.0.1', // Current application IP address
'80' // Current application port (default 80)
);
$logger = new Logger\SimpleHttpLogger([
'host' => 'http://127.0.0.1:9411' // Zipkin's API host with schema (http://) and without trailing slash
]);
$tracer = new Tracer(
'http://rpc/login', // Trace name
$endpoint, // Your application meta-information
$logger // Logger used to store/send traces
);
$tracer->setProfile(Tracer::FRONTEND);
$tracer->trace();
$requestStartTimestamp = zipkin_timestamp();
$spanIdentifier = new Identifier\SpanIdentifier();
/*
...
Request logic
Remember, you need to add B3 headers to your request:
X-B3-TraceId = TracerInfo::getTraceId();
X-B3-SpanId = $spanIdentifier;
X-B3-Sampled = TracerInfo::isSampled();
*/
sleep(1);
$endpoint = new Endpoint(
'rpc 1', // Name of service you're connecting with
'127.0.1.1', // This service Ip
'8000' // And port
);
$annotationBlock = new AnnotationBlock(
$endpoint,
$requestStartTimestamp
);
// 参数放到这里面
$metadata = new Metadata();
$metadata->set("file" , __FILE__);
$span = new Span(
$spanIdentifier,
'rpc 1',
$annotationBlock,
$metadata
);
$tracer->addSpan($span);
$tracer->trace();
$requestStartTimestamp = zipkin_timestamp();
$spanIdentifier = new Identifier\SpanIdentifier();
sleep(2);
/*
...
Request logic
Remember, you need to add B3 headers to your request:
X-B3-TraceId = TracerInfo::getTraceId();
X-B3-SpanId = $spanIdentifier;
X-B3-Sampled = TracerInfo::isSampled();
*/
$endpoint = new Endpoint(
'rpc 2', // Name of service you're connecting with
'127.0.1.1', // This service Ip
'8000' // And port
);
$annotationBlock = new AnnotationBlock(
$endpoint,
$requestStartTimestamp
);
$span = new Span(
$spanIdentifier,
'Rcp 2',
$annotationBlock
);
$tracer->addSpan($span);
$tracer->trace();
回复
Recommend
相关搜索关键词
- Top团队大牛带你玩转Android性能分析与优化
- 使用本地缓存优化微服务
- visa卡使用场景
- 图静态分析
- 静态分析
- @@dPXB7/blog/wp-admin/setup-config.php?step=0
- @@dPXB7/mirasvit_adminer_431.php
- @@dPXB7/mirasvit_adminer-4.2.3.php
- @@dPXB7/site/wp-admin/setup-config.php?step=0
- @@dPXB7/latest-mysql.php
- @@dPXB7/latest-mysql-en.php
- @@dPXB7/wp-admin/adminer.php
- @@dPXB7/adminer-4.3.0.php
- @@dPXB7/test/wp-admin/setup-config.php?step=0
- @@dPXB7/wp-login.php
- @@dPXB7/mirasvit_adminer_mysql.php
- @@dPXB7/adminer-4.7.0.php
- php and 5759=5759-- iuuq
- @@dPXB7/adminer1.php
- php and 9438=3142-- fruq
- @@dPXB7/wp/wp-admin/setup-config.php?step=0
- @@dPXB7/wp-includes/ID3/module.audio.ac3.php
- @@dPXB7/adminer/adminer.php
- PHP
- @@dPXB7/wp-content/uploads/2022/10/settings_auto.php
- @@dpxb7/wp-content/plugins/hd-webplayer/playlist.php
- @@dPXB7/latest.php
- PHP AND 7873=9865
- @@dPXB7/wp-admin/setup-config.php?step=0
- php
Recent search keywords
- bead
- plus de 8000 chaines
- 回来找我
- inspector calls
- Louisiana
- Self-enabling
- flexibility
- Infrastructure
- United Arab Emirates
- repurpose
- El Salvador Colon US Dollar
- Mountains
- Switzerland
- indexing
- Ergonomic
- e-markets
- Administrator
- Sausages
- Program
- engineer
- Bahrain
- cross-media
- product
- holistic
- Ports
- Open-architected
- Synergistic
- Automotive
- Moroccan Dirham
- Generic Steel Salad
- communities
- algorithm
- Kina
- reboot
- Future
- SMTP
- Lake
- Cotton
- Clothing
- monetize
- revolutionize
- purple
- Generic
- Tirol
- Applications
- architecture
- Customizable
- portals
- Rubber
- Integrated
- Total
- Credit Card Account
- Avon
- User-friendly
- Angola
- schemas
- US Dollar
- clicks-and-mortar
- Pants
- Grnit
- Intelligent
- multi-byte
- Filippinerna
- online
- -1" or 3+860-860-1=0+0+0+1 --
- answers
- @@l00ww
- iecho.cc
- golbel
- 129084
- cssbuilder
- DOVE加速器
- Graphcore
- n950f
- eb341820cd3a3485461a61b1e97d31b1
- onepiece
- Samsung gaming
- contact
- hindi
- golang9478590
- http\x3A\x2F\x2Fbestbuy.com
- 哥们
- 黑兽
- -4307" or 5781=5781 and "yvut"="yvut
- yiyo
- Inda
- -1" or 2+501-501-1=0+0+0+1 --
- upi
- 印度支付通道
- AC8227L+Android+head+unit+4gb/32gb
- xperia+5+v
- org+chart
- Iptv+2023
- san+francisco+web+development
- 8257+logo
- hacks+in+blooket
- 深入理解+Gem5
- xperia+5+v+kernel
- hacks in blooket
- Iptv 2023