0

From react application (App.js ) imported jaeger-client. import jaegerClient from 'jaeger-client'

Got exception 'TypeError: _fs2.default.readFileSync is not a function' from following line of /node_modules/jaeger-client/dist/src/thrift.js:168 source: _fs2.default.readFileSync(_path2.default.join(__dirname, './jaeger-idl/thrift/jaeger.thrift'), 'ascii')

Trying to solve it. Thanks for any help.

Complete package.json is like below { "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" } }

Forked from https://github.com/ahfarmer/calculator and I am trying to trace every user action ( button press ). To test tracing from react.js application.

Debmalya Jash
  • 301
  • 1
  • 11

2 Answers2

2

node-jaeger-client currently doesn't run in the browser. There is ongoing work to make jaeger-client browser friendly. This issue: readFileSync is not a function contains relevant information to why you're seeing the error message. Essentially, you're trying to run jaeger-client (a nodejs library) using react-scripts which doesn't contain the modules that jaeger-client needs.

0

Not jaeger, able to send traces to zipkin server, using zipkin-simple. Related code is in repository 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>"
   }) 
Debmalya Jash
  • 301
  • 1
  • 11