将 OpenTelemetry 跟踪数据从 Spring 启动应用程序导入 Elastic APM - 视图缺少数据

Importing OpenTelemetry trace data from Spring Boot application to Elastic APM - views are missing data

我有一个 Spring 启动应用程序,其中包含 Spring Cloud Sleuth、OpenTelemetry 工具和 OpenTelemetry 导出器 OTLP。

这是依赖的要点:

我的 application.yml 中只有基本配置:

spring:
  sleuth:
    enabled: true
    otel:
      config:
        trace-id-ratio-based: 1.0
      exporter:
        otlp:
          endpoint: http://localhost:8200

通过此设置,我成功地在 APM 中看到了一些数据。示例屏幕:

但是,如果我查看 Elastic 文档,我会发现他们的屏幕显示了额外的数据:Traces

对我来说,似乎缺少跨度和事务名称(我只看到 HTTP GET 而不是名称),至少它们存在于文档图像中。

有人知道为什么会发生这种情况以及如何解决这个问题吗?

这是 Elastic 中的示例跟踪文档:

const EXAMPLE = {
  "_index": "apm-7.15.2-metric-000001",
  "_type": "_doc",
  "_id": "AYVKCH8BxjGANUnHPDgq",
  "_version": 1,
  "_score": 1,
  "_source": {
    "_doc_count": 2,
    "agent": {
      "name": "opentelemetry/java"
    },
    "processor": {
      "name": "metric",
      "event": "metric"
    },
    "transaction.duration.histogram": {
      "counts": [
        1,
        1
      ],
      "values": [
        1439,
        10495
      ]
    },
    "metricset.name": "transaction",
    "observer": {
      "hostname": "0798ff612508",
      "id": "6a12bcef-5e7e-45b3-aee6-f2af4e175c3f",
      "ephemeral_id": "389ee9b1-d4c4-4d67-b46a-bfcaa77b7b79",
      "type": "apm-server",
      "version": "7.15.2",
      "version_major": 7
    },
    "@timestamp": "2022-02-17T15:25:56.160Z",
    "timeseries": {
      "instance": "summary-service:HTTP GET:11ed2dc65a946e45"
    },
    "ecs": {
      "version": "1.11.0"
    },
    "service": {
      "name": "summary-service"
    },
    "event": {
      "ingested": "2022-02-17T15:25:57.161730700Z",
      "outcome": "success"
    },
    "transaction": {
      "result": "HTTP 2xx",
      "root": true,
      "name": "HTTP GET",
      "type": "request"
    }
  },
  "fields": {
    "transaction.name.text": [
      "HTTP GET"
    ],
    "_doc_count": [
      2
    ],
    "service.name": [
      "summary-service"
    ],
    "processor.name": [
      "metric"
    ],
    "observer.version_major": [
      7
    ],
    "observer.hostname": [
      "0798ff612508"
    ],
    "transaction.result": [
      "HTTP 2xx"
    ],
    "transaction.duration.histogram": [
      {
        "counts": [
          1,
          1
        ],
        "values": [
          1439,
          10495
        ]
      }
    ],
    "transaction.type": [
      "request"
    ],
    "metricset.name": [
      "transaction"
    ],
    "observer.id": [
      "6a12bcef-5e7e-45b3-aee6-f2af4e175c3f"
    ],
    "event.ingested": [
      "2022-02-17T15:25:57.161Z"
    ],
    "@timestamp": [
      "2022-02-17T15:25:56.160Z"
    ],
    "observer.ephemeral_id": [
      "389ee9b1-d4c4-4d67-b46a-bfcaa77b7b79"
    ],
    "timeseries.instance": [
      "summary-service:HTTP GET:11ed2dc65a946e45"
    ],
    "observer.version": [
      "7.15.2"
    ],
    "ecs.version": [
      "1.11.0"
    ],
    "observer.type": [
      "apm-server"
    ],
    "transaction.root": [
      true
    ],
    "processor.event": [
      "metric"
    ],
    "transaction.name": [
      "HTTP GET"
    ],
    "agent.name": [
      "opentelemetry/java"
    ],
    "event.outcome": [
      "success"
    ]
  }
}

To me, it looks like span and transaction names are missing (I only see HTTP GET instead of a name)

不,他们没有失踪。您看到 name 为 HTTP GET 的原因是由于偏好较少的基数名称和跟踪数据的语义约定。这里有关于 HTTP 跨度命名约定的详细解释 https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#name。 auto-instrumentation 库生成的任何数据都将遵守语义约定规范。我猜来自链接供应商的可视化来自手动检测,您作为最终用户可以在其中给出任何名称(尽管建议每个人都使用较少的基数,但那里没有强制执行)。我不认为这里有什么可以“修复”的。