从反应应用程序(App.js)导入jaeger-client。
import jaegerClient from 'jaeger-client'
得到异常' TypeError:_fs2.default.readFileSync不是函数'来自/node_modules/jaeger-client/dist/src/thrift.js:168的以下行
source: _fs2.default.readFileSync(_path2.default.join(__dirname, './jaeger-idl/thrift/jaeger.thrift'), 'ascii')
试图解决它。谢谢你的帮助。
完整的package.json如下所示
{
"name": "calculator",
"version": "0.1.0",
"private": true,
"homepage": "http://ahfarmer.github.io/calculator",
"devDependencies": {
"gh-pages": "^1.1.0",
"react-scripts": "^1.0.17"
},
"dependencies": {
"ajv": "^6.4.0",
"ajv-keywords": "^3.1.0",
"big.js": "^5.0.3",
"bufferutil": "^3.0.3",
"fs": "0.0.1-security",
"github-fork-ribbon-css": "^0.2.1",
"hexer": "^1.5.0",
"jaeger-client": "^3.10.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-tracing": "^0.1.5",
"thrift": "^0.11.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "./node_modules/react-scripts/config/eslint.js"
}
}
从https://github.com/ahfarmer/calculator分叉,我正在尝试跟踪每个用户操作(按下按钮)。从react.js应用程序测试跟踪。
答案 0 :(得分:1)
node-jaeger-client目前不在浏览器中运行。正在进行work以使jaeger-client浏览器友好。此问题:readFileSync is not a function包含您查看错误消息的相关信息。基本上,您正在尝试使用不包含jaeger-client所需模块的react-scripts运行jaeger-client(nodejs库)。
答案 1 :(得分:0)
不是jaeger,能够使用zipkin-simple向zipkin服务器发送痕迹。 相关代码位于存储库https://github.com/debmalya/calculator
中import zipkinSimple from 'zipkin-simple'
const zipkinTracerSimple = new zipkinSimple({
debug: true,
host: "localhost",
port: "9411",
path: "/api/v2/spans",
sampling: 1.0,
})
var zipkinSimpleTraceData
zipkinSimpleTraceData= zipkinTracerSimple.getChild(zipkinSimpleTraceData);
zipkinSimpleTraceData =
zipkinTracerSimple.sendClientSend(zipkinSimpleTraceData, {
service: '<service_name>',
name: "<span_name>"
})