PHPackages                             easyops-cn/easykin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. easyops-cn/easykin

ActiveLibrary

easyops-cn/easykin
==================

A simple zipkin implementation for php.

0.3.6(3y ago)913.1k2[1 PRs](https://github.com/easyops-cn/easykin/pulls)MITPHPPHP &gt;=7.0

Since Aug 25Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/easyops-cn/easykin)[ Packagist](https://packagist.org/packages/easyops-cn/easykin)[ RSS](/packages/easyops-cn-easykin/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (13)Used By (0)

easykin
=======

[](#easykin)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265 "Software License")](LICENSE)[![Build Status](https://camo.githubusercontent.com/21ecc699375a8449bf34d2b1f4f852996929b6542dd76e4990cacea3b920be58/68747470733a2f2f7472617669732d63692e6f72672f656173796f70732d636e2f656173796b696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/easyops-cn/easykin)

这是一个简单的Zipkin PHP库，根据 [官方概念文档](http://zipkin.io/pages/instrumenting.html) 实现，主要用于PHP实现的web服务链路追踪，并针对B3 Propagation封装了专用的Trace类，方便Http服务的接入。

Quick Start
-----------

[](#quick-start)

#### 初始化

[](#初始化)

定义服务基础信息:

```
EasyKin::setEndpoint(
	'My service', // 服务名
	'127.0.0.1', // 服务IP
	80); // 服务端口
```

定义trace信息上报方式，提供FileLogger和HttpLogger两种方式，可以基于Logger接口实现更多上报方式：

```
EasyKin::setLogger(
	new easyops\easykin\logger\HttpLogger(
		'http://127.0.0.1:9411/api/v1/spans', false));
```

***初始化Trace***

对于前端（链路的源头）：

```
EasyKin::setTrace(new \easyops\easykin\core\Trace('get:/login'));
```

对于后端，需要提取请求Header中的B3信息:

```
$traceId = !empty($_SERVER['HTTP_X_B3_TRACEID']) ? $_SERVER['HTTP_X_B3_TRACEID']) : null;
$parentSpanId = !empty($_SERVER['HTTP_X_B3_PARENTSPANID']) ? $_SERVER['HTTP_X_B3_PARENTSPANID'] : null;
$spanId = !empty($_SERVER['HTTP_X_B3_SPANID']) ? $_SERVER['HTTP_X_B3_SPANID'] : null;
$isSampled = !empty($_SERVER['HTTP_X_B3_SAMPLED'])) ? $_SERVER['HTTP_X_B3_SAMPLED'] : null;

EasyKin::setTrace(new \easyops\easykin\core\Trace('get:/login', $sampled, $traceId, $parentSpanId, $spanId));
```

也可以使用封装好的HttpTrace类，前后端调用方式都一致：

```
EasyKin::setTrace(new \easyops\easykin\core\HttpTrace());
```

以上动作均需在你的服务程序入口处尽早完成，在程序结尾处执行上报方法：

```
EasyKin::trace();
```

***注意：如果服务程序因为异常而中断，EasyKin依然会上报trace信息***

#### 新建一个Span

[](#新建一个span)

当你的服务发起请求时，需要新建一个Span来承载该请求的信息：

```
$span = EasyKin::newSpan(
	'get:/users', // span名字，这里以请求url作为名字
	'users service',  // 请求的服务名
	'127.0.0.1',      // 请求的服务IP
	8080);            // 请求的服务端口
```

然后执行你的请求逻辑。当请求结果返回后，应尽快执行：

```
$span->receive();
```

以便准确记录该请求的结束时间。

#### 执行上报

[](#执行上报)

当服务应用程序处理完一次请求后，需要执行上报动作：

```
EasyKin::trace();
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance54

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~473 days

Total

11

Last Release

1273d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.6

0.3.6PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f54eb92c7fa16adde3be6a063ec92eef7cbfbfebbbe1696c3a48f92c04e454eb?d=identicon)[cheukchiu](/maintainers/cheukchiu)

---

Top Contributors

[![indexzhuo](https://avatars.githubusercontent.com/u/1164909?v=4)](https://github.com/indexzhuo "indexzhuo (4 commits)")[![JLHwung](https://avatars.githubusercontent.com/u/3607926?v=4)](https://github.com/JLHwung "JLHwung (2 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (2 commits)")[![stallman-cui](https://avatars.githubusercontent.com/u/6100837?v=4)](https://github.com/stallman-cui "stallman-cui (1 commits)")

---

Tags

phpzipkinzipkin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/easyops-cn-easykin/health.svg)

```
[![Health](https://phpackages.com/badges/easyops-cn-easykin/health.svg)](https://phpackages.com/packages/easyops-cn-easykin)
```

###  Alternatives

[openzipkin/zipkin

A Zipkin instrumentation for PHP

2774.3M35](/packages/openzipkin-zipkin)[vinelab/tracing-laravel

Distributed tracing for Laravel made easy

80118.7k1](/packages/vinelab-tracing-laravel)[auxmoney/opentracing-bundle-core

Symfony Opentracing bundle to easily enable distributed tracing

25904.4k9](/packages/auxmoney-opentracing-bundle-core)[whitemerry/phpkin

PHP Zipkin implementation

7726.5k3](/packages/whitemerry-phpkin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
