0

从反应应用程序(App.js)导入 jaeger-client。 import jaegerClient from 'jaeger-client'

从 /node_modules/jaeger-client/dist/src/thrift.js:168 的以下行得到异常“TypeError:_fs2.default.readFileSync 不是函数” 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 应用程序测试跟踪。

4

2 回答 2

2

node-jaeger-client 当前不在浏览器中运行。使 jaeger-client 浏览器友好的工作正在进行中。此问题:readFileSync 不是一个函数,其中包含与您看到错误消息的原因相关的信息。本质上,您正在尝试使用不包含 jaeger-client 所需模块的 react-scripts 运行 jaeger-client (一个 nodejs 库)。

于 2018-04-03T19:24:22.093 回答
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>"
   }) 
于 2018-04-03T09:00:37.877 回答