Coder Social home page Coder Social logo

webman_tracer's Introduction

webmanTracer使用教程

webman的链路追踪组件,基于xiaoyangguang/webman_aop, 实现了基本的链路追踪组件, 比如mysql es redis 开发者可自定义追踪方法函数,实现自己需要追踪的组件,可追踪composer加载的三方库,比如thinkorm的数据库执行函数 (可选择自定义收集追踪上报数据类,并配置在tracer.php中 如果example无法满足你的需求)

安装

composer require xiaoyangguang/webman_tracer

配置 bootstrap.php文件

<?php
return [
     Xiaoyangguang\WebmanTracer\bootstrap\TracerInitialize::class,
     //....省略其他 
];

我们需要在 config 目录下,增加 tracer.php 配置

<?php
//区分大小写
use app\social\service\PostService;
use support\bootstrap\EsClient;
use support\Redis;
use think\db\PDOConnection;
use Xiaoyangguang\WebmanTracer\core\TracerInitialize;
use Xiaoyangguang\WebmanTracer\example\ElasticsearchAspect;
use Xiaoyangguang\WebmanTracer\example\GenericAspect;
use Xiaoyangguang\WebmanTracer\example\MysqlAspect;
use Xiaoyangguang\WebmanTracer\example\RedisAspect;

TracerInitialize::setConfig(true);
MysqlAspect::setConfig('业务数据库', '127.0.0.1');
RedisAspect::setConfig('业务Redis');
ElasticsearchAspect::setConfig('业务Elasticsearch');
//HttpAspect::setConfig();

return [
    RedisAspect::class => [ //追踪类
       Redis::class => [  //被追踪类
            '__callStatic', //被追踪方法
        ],
    ],
    ElasticsearchAspect::class => [//追踪类
        EsClient::class => [
            '__callStatic',//被追踪方法
            '__call',//被追踪方法
        ],
    ],
    MysqlAspect::class => [//追踪类
        PDOConnection::class => [  //追踪底层数据库执行方法例子
            'getPDOStatement',//被追踪方法
        ],
    ],
    GenericAspect::class => [ //追踪类 通用追踪节点 任由开发者发挥
        PostService::class => [
            'searchByIds',
        ],
    ],
];

最后启动服务,并测试。

docker run -d --restart always -p 9411:9411 --name zipkin openzipkin/zipkin 

php start.php start
curl  http://127.0.0.1:8787

在浏览器访问:http://ip:9411/zipkin/查看平台数据

avatar avatar

webman_tracer's People

Contributors

xioayangguang avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.