Zipkin-1.19.0学习系列2:Nodejs范例(Client Send,Client Receive))
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))相关推荐
- Zipkin-1.19.0学习系列1:java范例
2019独角兽企业重金招聘Python工程师标准>>> 官网地址: https://github.com/openzipkin/zipkin http://zipkin.io/ ht ...
- Zipkin-1.19.0学习系列13: Brave-Web-Filter的filter机制分析
2019独角兽企业重金招聘Python工程师标准>>> 设置断点 stop in com.freedom.monitor.myeye.client.tomcat.BraveFilte ...
- 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 ...
- 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学习系列文章- ...
- ExtJs2.0学习系列--Ext.Panel
ExtJs2.0学习系列--Ext.Panel 2008-06-29 12:59 上一篇文章ExtJs2.0学习系列(1)--Ext.MessageBox ,受到了大家的褒贬不一,还是有的朋友提出好的 ...
- 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 ...
- ExtJs2.0学习系列(12)--Ext.TreePanel之第一式
今天开始,我们就开始一起学习TreePanel了,道个歉,上篇的代码很乱阿. 我总是喜欢用最简单的例子开始,去理解最基本的使用方法,减少对i后面高级使用的干扰! TreePanel是继承自Panel, ...
- ExtJs2.0学习系列(6)--Ext.FormPanel之第三式(ComboBox篇)
前言:说句实话,此extjs系列的文章在博客园中的热度不高,可能是学这玩意的人不多吧,但是我觉得有这么个系列的文章对于中国朋友非常有帮助!请大家支持! 上篇ExtJs2.0学习系列(5)--Ext.F ...
- ExtJs2.0学习系列(5)--Ext.FormPanel之第二式
随笔- 71 文章- 10 评论- 1096 ExtJs2.0学习系列(5)--Ext.FormPanel之第二式 上篇中我们简单的谈到了FormPanel中的fieldset和ComboBox ...
- ExtJs2.0学习系列(4)--Ext.FormPanel之第一式
随笔- 71 文章- 10 评论- 1096 ExtJs2.0学习系列(4)--Ext.FormPanel之第一式 上篇中我们讨论了Ext.window的简单使用,今天我们要看看强大的FormP ...
最新文章
- 无法访问此网站刷新又好了_一键突破或加速网站访问
- boost::overloaded_function用法的测试程序
- C++虽不会过时,但是真的难啊!
- open source protocols
- 深入理解line-height与vertical-align——前端布局常用属性
- node静态服务器优缺点_使用 Node.js 的优势和劣势都有哪些?
- Web 的MSN,可以不用装客户端
- C# 检查字符串,防SQL注入攻击(转载)
- 蓝牙CC2540 CC2541常用AT指令集
- Linux内存管理宏观篇(五)物理内存:页面分配和释放页面
- 二调,分幅图打印(标准分幅土地利用现状图,耕地坡度分级图),图框工具
- 设计模式、重构.pdf
- 转贴: 柴静 采访 张朝阳
- Chrome启动页设置无效完美解决
- Android 在图片的指定位置添加标记
- 动物识别专家系统c语言代码,动物识别专家系统(C++版)
- Linux防火墙入门:基本观念(转)
- ——廖一梅《像我这样笨拙地生活》经典语录
- 如何在目录下创建文件linux,linux在目录下创建文件
- ApacheCN 公众号文章汇总 2019.5
热门文章
- 146.LRU缓存机制
- 编程实现strcmp函数
- 贪吃蛇程序 php,PHP下利用PHPMailer Web程序【tofacebook.com】 - 贪吃蛇
- mmp格式转换_mmp是什么意思
- 凸优化第二章凸集 2.3保凸运算
- 【机器学习系列】MCMC第三讲:理解MCMC前必先弄懂这两点
- 模拟https类型的get,post请求时,碰到证书不信任,无法正常获取返回内容的异常
- Servlet和JSP
- 【ZOJ 3715 —— 13年浙江省赛K】Kindergarten Election 【枚举答案进行判断】 【夺宝奇兵 —— CCPC-Wannafly Winter Camp Day1】
- 【dfs+简单贪心】Leaf Sets【Codeforces Round #510 (Div. 2)】