@opentelemetry/exporter-trace-otlp-grpc 升级导致未建立连接

问题描述 投票:0回答:1

我正在尝试更新以前工作的 Typesscript 服务,将指标和跟踪导出到 opentelemetry docker 容器以使用最新的 API,但我收到一个似乎与最近的 API 方法有关的连接错误:PeriodicExportingMetricReader

我的旅馆配置:

receivers:
    otlp:
        protocols:
            grpc:

exporters:
    prometheus:
        endpoint: '0.0.0.0:8889'
        namespace: B2B
        metric_expiration: 525600m

    jaeger:
        endpoint: jaeger:14250
        tls:
            insecure: true

processors:
    batch:

extensions:
    health_check:
    pprof:
        endpoint: :1888
    zpages:
        endpoint: :55679

service:
    extensions: [pprof, zpages, health_check]
    telemetry:
        logs:
            level: "info"
            development: true
            encoding: "json"
    pipelines:
        traces:
            receivers: [otlp]
            processors: [batch]
            exporters: [jaeger]
        metrics:
            receivers: [otlp]
            exporters: [prometheus]

我的包裹配置:

    "@opentelemetry/api": "^1.3.0",
    "@opentelemetry/api-metrics": "^0.33.0",
    "@opentelemetry/host-metrics": "^0.31.0",
    "@opentelemetry/sdk-metrics": "^1.8.0",
    "@opentelemetry/sdk-trace-node": "^1.8.0",

注意这个配置导入

"@opentelemetry/exporter-metrics-otlp-grpc": "^0.35.1",

我的代码如下:

export async function startTracing() {
  try {
    const collectorOptions = {
      url: `grpc://localhost:4317`,
    };

    const traceExporter = new OTLPTraceExporter(collectorOptions);

    const metricExporter = new PeriodicExportingMetricReader({
      exporter: new OTLPMetricExporter(collectorOptions),
      exportIntervalMillis: 5000,
    });

    const sdk = new NodeSDK({
      resource: new Resource(monitoringAttributes),
      traceExporter: traceExporter,
      metricReader: metricExporter,
      spanProcessor: new BatchSpanProcessor(traceExporter, {
        scheduledDelayMillis: 500,
      }),
      instrumentations: [
        new HttpInstrumentation(),
        new ExpressInstrumentation(),
      ],
    });

    await sdk
      .start()
      .then(() => console.log('Tracing initialized'))
      .catch((error) => console.log('Error initializing tracing', error));

    // gracefully shut down the SDK on process exit
    process.on('SIGTERM', () => {
      sdk
        .shutdown()
        .then(() => console.log('Tracing terminated'))
        .catch((error) => console.log('Error terminating tracing', error))
        .finally(() => process.exit(0));
    });
  } catch (e) {
    console.log('startTracing. error occurred', e);
  }
}


错误是:

2023-03-01 16:51:13 Service request {
2023-03-01 16:51:13   resourceMetrics: [
2023-03-01 16:51:13     { resource: [Object], schemaUrl: undefined, scopeMetrics: [Array] }
2023-03-01 16:51:13   ]
2023-03-01 16:51:13 }
2023-03-01 16:51:13 {"stack":"Error: PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established)\n    at PeriodicExportingMetricReader._doRun (/app/node_modules/@opentelemetry/sdk-metrics/src/export/PeriodicExportingMetricReader.ts:122:13)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)\n    at PeriodicExportingMetricReader._runOnce (/app/node_modules/@opentelemetry/sdk-metrics/src/export/PeriodicExportingMetricReader.ts:94:7)","message":"PeriodicExportingMetricReader: metrics export failed (error Error: 14 UNAVAILABLE: No connection established)","name":"Error"}

我非常感谢关于问题可能是什么的任何线索

javascript typescript nest open-telemetry
1个回答
-3
投票

你好劳伦斯你有更多关于这个问题的线索还是你找到了什么?

© www.soinside.com 2019 - 2024. All rights reserved.