当前位置: 首页 > 知识库问答 >
问题:

开放遥测Nodejs-将收集器连接到仪器

万俟修诚
2023-03-14

我正在尝试为Lightstep中的Hello world示例设置跟踪安装https://lightstep.com/blog/opentelemetry-nodejs/:

const express = require("express");

const PORT = process.env.PORT || "8080";
const app = express();

app.get("/", (req, res) => {
  res.send("Hello World");
});

app.listen(parseInt(PORT, 10), () => {
  console.log(`Listening for requests on http://localhost:${PORT}`);
});

我的tracing.js如下:

'use strict';

const opentelemetry = require('@opentelemetry/api');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { BatchSpanProcessor } = require("@opentelemetry/tracing");
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { autoinstrumentationsnode } = require('@opentelemetry/auto-instrumentations-node');

module.exports = () => {
 const provider = new NodeTracerProvider();

 const exporterOptions = {
  serviceName: "my-service-name",
  url: "http://localhost:4317",
 }


 const exporter = new CollectorTraceExporter(exporterOptions);
 provider.addSpanProcessor(new BatchSpanProcessor(exporter));
 provider.register();

 registerInstrumentations({
  instrumentations: [
    new autoinstrumentationsnode(),
  ],
 })
 return opentelemetry.trace.getTracer("instrumentation-example");
}

我的收集器正在本地主机4317上侦听,配置文件如下:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: "localhost:4317"

exporters:
  logzio:
    account_token: token

processors:
  batch:

extensions:
  pprof:
    endpoint: :1777
  zpages:
    endpoint: :55679
  health_check:

service:
  extensions: [health_check, pprof, zpages]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [logzio]

我正在运行otelcontribcol\u darwin\u amd64版本23。它会将痕迹发送到我的logz。io帐户。它适用于Java和Python应用程序。

node.js我卡住了。终端说节点在localhost:8080上运行,但它就是不向任何地方发送任何痕迹。当我将输出更改为控制台时,它确实会向我显示痕迹。所以问题出在收集器和仪器之间的通信中。

你能告诉我我该怎么解决这个问题吗?

非常感谢!

共有2个答案

潘意
2023-03-14

请检查应始终保持最新的示例https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/collector-exporter-node

首先,我可以看到不需要在配置中定义“endpoint”。您还可以跳过“exporterOptions”中的“url”参数,以便使用默认值。

请尝试使用最新版本的收集器以及,我一直在使用"otel/opentelemetry-收集器:0.30.0"和它的作品对我来说很好。

宗政斌
2023-03-14

您在哪里找到收集器urlhttp://localhost:4317 ?这是不正确的配置。截至今天,端口4317保留给grpc,端口55681保留给http。当您使用http发送遥测数据时,应该按照此处的建议为每个信号(跟踪/度量/日志)配置url。使用更新收集器urlhttp://localhost:55681/v1/traces应该解决这个问题。

 类似资料:
  • 我们将有一个高负荷的遥测服务。我正在寻找能够扩展收集器和后端(zipkin)的解决方案 有一种扩展zipkin的解决方案。看起来很简单-只需使用内部平衡 但是,我找不到使用多个openTelemetry收集器的示例。运行几个收集器实例没有什么问题,但我如何说“myApp”来平衡它们呢?在Exporters中没有这样的选项。

  • 我正在尝试从节点将度量导出到OpenTelemetry收集器容器。js应用程序,然后将其导出到New Relic。 我正在制作一个简单的请求计数器: 我想使用status code属性,以便能够在New Relic中按不同的状态代码进行刻面/分组。为此,我需要在每个请求旁边导出状态代码属性(标签),以便在New Relic中使用它们。但是,这些标签不会在OTLP中导出,也不会显示在日志导出器中。我

  • 问题内容: 我在将作为docker容器运行的nodeJS应用程序连接到mongoDB时遇到问题。让我解释一下到目前为止我做了什么: 如您所见,已经有一个mongo docker容器正在运行。 现在我正在运行我的nodeJS应用程序docker容器(这是来自meteorJS的构建): 在这个Docker容器中,我想通过运行以下命令来运行应用程序: 现在我得到了错误 我已经尝试通过设置以下内容来设置M

  • 我有一个nodejs聊天服务器,它有不同的事件“Connection”,“SendChat”,“Switchroom”... null Thx很多!

  • 我在将开放遥测数据导出并发送到newRelic的GRPCendpoint时遇到问题。这是我尝试连接到newRelicendpoint的代码片段: 它卡在步道里了。新的。 我是开放遥测的新手,我读了打开的遥测留档,我可以在控制台中打印Otel数据,但是当我想将其导出到newrelic时,它不起作用。我也读了newRelic Otel留档,他们有一个导出器SDK但是它停止了,他们提供了这个新的GRPC

  • 我已经运行了官方的Otel collector文档,并使用Docker和以下配置/代码文件运行了collector,但当应用程序尝试发布到/v1/tracesendpoint时,总能从collector获得404。我也尝试过各种代码示例,这篇文章,在macOS和Ubuntu上运行收集器,使用旧版本,但都没有成功。偶数<代码>卷曲-s-X柱'http://localhost:55681/v1/tra