2

我正在使用开放遥测来导出以下应用程序的跟踪信息:

  1. nodejs kafka 生产者将消息发送到input-topic. 它使用带有库的kafkajs仪器。opentelemetry-instrumentation-kafkajs我将 AWS OTEL 中的示例用于 NodeJS示例。这是我的tracer.js
module.exports = () => {
  diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR);

  // create a provider for activating and tracking with AWS IdGenerator
  const attributes = {
      'service.name': 'nodejs-producer',
      'service.namespace': 'axel'
  }

  let resource = new Resource(attributes)

  const tracerConfig = {
    idGenerator: new AWSXRayIdGenerator(),
    plugins: {
        kafkajs: { enabled: false, path: 'opentelemetry-plugin-kafkajs' }
    },
    resource: resource
  };
  const tracerProvider = new NodeTracerProvider(tracerConfig);

  // add OTLP exporter
  const otlpExporter = new CollectorTraceExporter({
    url: (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) ? process.env.OTEL_EXPORTER_OTLP_ENDPOINT : "localhost:55680"
  });
  tracerProvider.addSpanProcessor(new SimpleSpanProcessor(otlpExporter));
  tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

  // Register the tracer with X-Ray propagator
  tracerProvider.register({
    propagator: new AWSXRayPropagator()
  });

  registerInstrumentations({
    tracerProvider,
    instrumentations: [new KafkaJsInstrumentation({})],
  });

  // Return a tracer instance
  return trace.getTracer("awsxray-tests");
}

  1. 一个 Java 应用程序,它input-topicfinal-topic. 还使用 AWS OTEL java 代理进行检测。Java应用程序启动如下:
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
export OTEL_PROPAGATORS=xray
export OTEL_RESOURCE_ATTRIBUTES="service.name=otlp-consumer-producer,service.namespace=axel"
export OTEL_METRICS_EXPORTER=none

java -javaagent:"${PWD}/aws-opentelemetry-agent.jar" -jar "${PWD}/target/otlp-consumer-producer.jar"
  1. 我正在使用otel/opentelemetry-collector-contrib具有 AWS XRay 导出器:
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317

exporters:
  awsxray:
    region: 'eu-central-1'
    max_retries: 10

service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [awsxray]

我可以从日志消息和 XRay 控制台中看到正在发布跟踪(具有正确的父跟踪 ID)。NodeJS 日志消息:

{
  traceId: '60d0c7d4cfc2d86b2df8624cb4bccead',
  parentId: undefined,
  name: 'input-topic',
  id: '3e289f00c4499ae8',
  kind: 3,
  timestamp: 1624295380734468,
  duration: 3787,
  attributes: {
    'messaging.system': 'kafka',
    'messaging.destination': 'input-topic',
    'messaging.destination_kind': 'topic'
  },
  status: { code: 0 },
  events: []
}

和带有标头的 Java 使用者:

Headers([x-amzn-trace-id:Root=1-60d0c7d4-cfc2d86b2df8624cb4bccead;Parent=3e289f00c4499ae8;Sampled=1])

如您所见,父 ID 和根 ID 相互匹配。然而,服务地图是以断开连接的方式构建的: 服务地图

我在这里缺少什么其他配置来编译正确的服务地图?

4

0 回答 0