2019独角兽企业重金招聘Python工程师标准>>>

下面需要研究Nodejs的例子,找了下zipkin的装备库,看到有一个

http://zipkin.io/pages/existing_instrumentations

分为自家研发版 vs 社区吃瓜群众版,

---在里面找到一个js的库,https://github.com/openzipkin/zipkin-js

下面开始研究Nodejs如何上报信息。

http://stackoverflow.com/questions/39014203/is-it-possible-to-modify-polymer-iron-ajax-element-to-use-cujojs-resthttps://github.com/openzipkin/zipkin-js/tree/master/packages/zipkin-instrumentation-cujojs-rest

====================================================

按照官方的说法,先执行

npm install zipkin --save

===然后, 找到了2个可能有帮助的库

https://github.com/openzipkin/zipkin-js/tree/master/packages/zipkin-transport-http

&

https://github.com/openzipkin/zipkin-js/tree/master/packages/zipkin-instrumentation-cujojs-rest

感觉zipkin-instrumentation-cujojs-rest比较有戏。

先安装这个库

npm install zipkin-instrumentation-cujojs-rest

npm install zipkin-transport-http

npm install --save rest

然后,例子参考:http://stackoverflow.com/questions/39014203/is-it-possible-to-modify-polymer-iron-ajax-element-to-use-cujojs-rest

源码如下:

const {Tracer,BatchRecorder,ExplicitContext} = require('zipkin');
const {HttpLogger}= require('zipkin-transport-http')
const {restInterceptor} = require('zipkin-instrumentation-cujojs-rest');const rest= require('rest');
console.log("1---");const ctxImpl = new ExplicitContext();
const recorder = new BatchRecorder({logger: new HttpLogger({endpoint: 'http://localhost:9411/api/v1/spans'})
});
//
const tracer = new Tracer({ctxImpl, recorder}); // configure your tracer properly here
const nameOfRemoteService = 'youtube';
const client = rest.wrap(restInterceptor, {tracer, remoteServiceName: nameOfRemoteService});//
//
var http= require('http');
http.createServer(function (req, res) {// Your application code here
client
({method:'GET',path: 'http://www.163.com/'}
)
.then
(success => {console.log('got result from YouTube');}, error => {console.error('Error', error);}
);// Your application code end
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}
)
.listen(1337, "0.0.0.0");
console.log('Server running at http://0.0.0.0:1337/');

在zipkin的界面上可以看到有数据产生,

然后还有一个问题就是ID的传递,抓包如下:

证明,ID是可以自动传递到下一个进程的。

---------------------------------------------------之前搞错了一个事情,就是这里只是弄好了cs,cr事件,

没有解决sr,ss事件,然后在网上找到了

https://www.npmjs.com/package/zipkin-simple

发现好像也帮不上什么忙,还是直接用官方的zipkin-js.

转载于:https://my.oschina.net/qiangzigege/blog/819035

Zipkin-1.19.0学习系列2:Nodejs范例(Client Send,Client Receive))相关推荐

  1. Zipkin-1.19.0学习系列1:java范例

    2019独角兽企业重金招聘Python工程师标准>>> 官网地址: https://github.com/openzipkin/zipkin http://zipkin.io/ ht ...

  2. Zipkin-1.19.0学习系列13: Brave-Web-Filter的filter机制分析

    2019独角兽企业重金招聘Python工程师标准>>> 设置断点 stop in com.freedom.monitor.myeye.client.tomcat.BraveFilte ...

  3. ASP.NET MVC 3.0学习系列文章(开始学习MVC)

    Visual Studio 11安装ASP.NET MVC4体验 Nic Pei 2011-09-27 23:15 阅读:2891 评论:11   微软build大会.net平台大事汇总 Nic Pe ...

  4. ASP.NET MVC 3.0学习系列文章—Model in ASP.NET MVC 3.0

    系列文章 ASP.NET MVC 3.0学习系列文章-序 ASP.NET MVC 3.0学习系列文章--Razor and ASP.NET MVC 3.0 ASP.NET MVC 3.0学习系列文章- ...

  5. ExtJs2.0学习系列--Ext.Panel

    ExtJs2.0学习系列--Ext.Panel 2008-06-29 12:59 上一篇文章ExtJs2.0学习系列(1)--Ext.MessageBox ,受到了大家的褒贬不一,还是有的朋友提出好的 ...

  6. ASP.NET MVC 3.0学习系列文章--Razor and ASP.NET MVC 3.0

    系列文章 ASP.NET MVC 3.0学习系列文章-序 Razor and ASP.NET MVC 3.0 ASP.NET MVC 3.0学习系列文章-Controllers in ASP.NET ...

  7. ExtJs2.0学习系列(12)--Ext.TreePanel之第一式

    今天开始,我们就开始一起学习TreePanel了,道个歉,上篇的代码很乱阿. 我总是喜欢用最简单的例子开始,去理解最基本的使用方法,减少对i后面高级使用的干扰! TreePanel是继承自Panel, ...

  8. ExtJs2.0学习系列(6)--Ext.FormPanel之第三式(ComboBox篇)

    前言:说句实话,此extjs系列的文章在博客园中的热度不高,可能是学这玩意的人不多吧,但是我觉得有这么个系列的文章对于中国朋友非常有帮助!请大家支持! 上篇ExtJs2.0学习系列(5)--Ext.F ...

  9. ExtJs2.0学习系列(5)--Ext.FormPanel之第二式

    随笔- 71  文章- 10  评论- 1096  ExtJs2.0学习系列(5)--Ext.FormPanel之第二式 上篇中我们简单的谈到了FormPanel中的fieldset和ComboBox ...

  10. ExtJs2.0学习系列(4)--Ext.FormPanel之第一式

    随笔- 71  文章- 10  评论- 1096  ExtJs2.0学习系列(4)--Ext.FormPanel之第一式 上篇中我们讨论了Ext.window的简单使用,今天我们要看看强大的FormP ...

最新文章

  1. 无法访问此网站刷新又好了_一键突破或加速网站访问
  2. boost::overloaded_function用法的测试程序
  3. C++虽不会过时,但是真的难啊!
  4. open source protocols
  5. 深入理解line-height与vertical-align——前端布局常用属性
  6. node静态服务器优缺点_使用 Node.js 的优势和劣势都有哪些?
  7. Web 的MSN,可以不用装客户端
  8. C# 检查字符串,防SQL注入攻击(转载)
  9. 蓝牙CC2540 CC2541常用AT指令集
  10. Linux内存管理宏观篇(五)物理内存:页面分配和释放页面
  11. 二调,分幅图打印(标准分幅土地利用现状图,耕地坡度分级图),图框工具
  12. 设计模式、重构.pdf
  13. 转贴: 柴静 采访 张朝阳
  14. Chrome启动页设置无效完美解决
  15. Android 在图片的指定位置添加标记
  16. 动物识别专家系统c语言代码,动物识别专家系统(C++版)
  17. Linux防火墙入门:基本观念(转)
  18. ——廖一梅《像我这样笨拙地生活》经典语录
  19. 如何在目录下创建文件linux,linux在目录下创建文件
  20. ApacheCN 公众号文章汇总 2019.5

热门文章

  1. 146.LRU缓存机制
  2. 编程实现strcmp函数
  3. 贪吃蛇程序 php,PHP下利用PHPMailer Web程序【tofacebook.com】 - 贪吃蛇
  4. mmp格式转换_mmp是什么意思
  5. 凸优化第二章凸集 2.3保凸运算
  6. 【机器学习系列】MCMC第三讲:理解MCMC前必先弄懂这两点
  7. 模拟https类型的get,post请求时,碰到证书不信任,无法正常获取返回内容的异常
  8. Servlet和JSP
  9. 【ZOJ 3715 —— 13年浙江省赛K】Kindergarten Election 【枚举答案进行判断】 【夺宝奇兵 —— CCPC-Wannafly Winter Camp Day1】
  10. 【dfs+简单贪心】Leaf Sets【Codeforces Round #510 (Div. 2)】