OpenCensus Tracer-OpenCensus服务的NodeJS导出器

时间:2019-03-14 19:19:15

标签: node.js exporter opencensus

尝试使用以下导出器https://github.com/census-instrumentation/opencensus-node/tree/master/packages/opencensus-exporter-ocagent将所有OpenCensus跟踪发送到OpenCensus Agent

这是我的代码

const tracing = require('@opencensus/nodejs')
let tracer = null

if(EXPORTER == "Zipkin"){
  const zipkin = require('@opencensus/exporter-zipkin')
  tracer = tracing.start({samplingRate: 1}).tracer;
  tracer.registerSpanEventListener(new zipkin.ZipkinTraceExporter({
    url: 'http://localhost:9411/api/v2/spans',
    serviceName: 'myapp'
}))
} else{
    const ocagent = require('@opencensus/exporter-ocagent')
    tracer = tracing.start({samplingRate: 1}).tracer;
    tracer.registerSpanEventListener(new ocagent.OCAgentExporter({
      serviceName: 'myapp',
      port: 55678
  }))
}

Zipkin导出器运行良好,但对于opencensus跟踪器代理导出器却出现以下错误

node_modules/@opencensus/exporter-ocagent/build/src/ocagent.js:85
        new proto.opencensus.proto.agent.trace.v1.TraceService(serverAddress, this.config.credentials);
                             ^

TypeError: Cannot read property 'proto' of undefined
at new OCAgentExporter (node_modules/@opencensus/exporter-ocagent/build/src/ocagent.js:85:34)

我在这里缺少任何依赖吗?

这是我的package.json依赖项

"dependencies": {
  "@opencensus/exporter-ocagent": "0.0.9",
  "@opencensus/exporter-prometheus": "0.0.9",
  "@opencensus/exporter-zipkin": "0.0.9",
  "@opencensus/nodejs": "0.0.9"
}

0 个答案:

没有答案