|
| 1 | +--- |
| 2 | +default_lang_commit: 8a5b880c16d49257a147c2c3ec4a6ef6fcee8e20 |
| 3 | +--- |
| 4 | + |
| 5 | +将遥测数据发送到 [OpenTelemetry Collector](/docs/collector/),以确保其被正确导出。 |
| 6 | +在生产环境中使用 Collector 是最佳实践。若要可视化你的遥测数据,可将其导出到后端系统,例如 |
| 7 | +[Jaeger](https://jaegertracing.io/)、[Zipkin](https://zipkin.io/)、 |
| 8 | +[Prometheus](https://prometheus.io/),或某个[特定厂商的](/ecosystem/vendors/)后端。 |
| 9 | + |
| 10 | +{{ if $name }} |
| 11 | + |
| 12 | +## 可用的导出器 {#available-exporters} |
| 13 | + |
| 14 | +镜像仓库中包含一份 [{{ $name }} 可用导出器的列表][reg]。 |
| 15 | + |
| 16 | +{{ end }} |
| 17 | + |
| 18 | +{{ if not $name }} |
| 19 | + |
| 20 | +镜像仓库中包含[按语言分类的导出器列表][reg]。 |
| 21 | + |
| 22 | +{{ end }} |
| 23 | + |
| 24 | +在所有导出器中,[OpenTelemetry 协议 (OTLP)][OTLP] 导出器是以 OpenTelemetry 数据模型为基础设计的, |
| 25 | +能够无信息丢失地输出 OTel 数据。此外,许多处理遥测数据的工具都支持 OTLP |
| 26 | +(例如 [Prometheus]、[Jaeger] 和大多数[厂商][vendors]),在你需要时为你提供高度的灵活性。 |
| 27 | +若要了解更多关于 OTLP 的信息,请参阅 [OTLP 规范][OTLP]。 |
| 28 | + |
| 29 | +[Jaeger]: /blog/2022/jaeger-native-otlp/ |
| 30 | +[OTLP]: /docs/specs/otlp/ |
| 31 | +[Prometheus]: https://prometheus.io/docs/prometheus/2.55/feature_flags/#otlp-receiver |
| 32 | +[reg]: </ecosystem/registry/?component=exporter&language={{ $lang }}> |
| 33 | +[vendors]: /ecosystem/vendors/ |
| 34 | + |
| 35 | +{{ if $name }} |
| 36 | + |
| 37 | +本页面介绍了主要的 OpenTelemetry {{ $name }} 导出器以及如何进行配置。 |
| 38 | + |
| 39 | +{{ end }} |
| 40 | + |
| 41 | +{{ if $zeroConfigPageExists }} |
| 42 | + |
| 43 | +{{% alert title=注意 %}} |
| 44 | + |
| 45 | +如果你使用了[零代码自动插桩](</docs/zero-code/{{ $langIdAsPath }}>), |
| 46 | +你可以参考[配置指南](</docs/zero-code/{{ $langIdAsPath }}/configuration/>)来了解如何设置导出器。 |
| 47 | + |
| 48 | +{{% /alert %}} |
| 49 | + |
| 50 | +{{ end }} |
| 51 | + |
| 52 | +{{ if $supportsOTLP }} |
| 53 | + |
| 54 | +## OTLP |
| 55 | + |
| 56 | +### Collector 设置 {#collector-setup} |
| 57 | + |
| 58 | +{{% alert title=注意 %}} |
| 59 | + |
| 60 | +如果你已经配置好 OTLP Collector 或后端,可以跳过此部分, |
| 61 | +直接[设置应用的 OTLP 导出器依赖](#otlp-dependencies)。 |
| 62 | + |
| 63 | +{{% /alert %}} |
| 64 | + |
| 65 | +为测试和验证你的 OTLP 导出器,你可以运行一个 Docker 容器形式的 Collector,将遥测数据直接输出到控制台。 |
| 66 | + |
| 67 | +在一个空目录下创建名为 `collector-config.yaml` 的文件,并添加以下内容: |
| 68 | + |
| 69 | +```yaml |
| 70 | +receivers: |
| 71 | + otlp: |
| 72 | + protocols: |
| 73 | + grpc: |
| 74 | + endpoint: 0.0.0.0:4317 |
| 75 | + http: |
| 76 | + endpoint: 0.0.0.0:4318 |
| 77 | +exporters: |
| 78 | + debug: |
| 79 | + verbosity: detailed |
| 80 | +service: |
| 81 | + pipelines: |
| 82 | + traces: |
| 83 | + receivers: [otlp] |
| 84 | + exporters: [debug] |
| 85 | + metrics: |
| 86 | + receivers: [otlp] |
| 87 | + exporters: [debug] |
| 88 | + logs: |
| 89 | + receivers: [otlp] |
| 90 | + exporters: [debug] |
| 91 | +``` |
| 92 | +
|
| 93 | +然后运行以下命令,在 Docker 容器中启动 Collector: |
| 94 | +
|
| 95 | +```shell |
| 96 | +docker run -p 4317:4317 -p 4318:4318 --rm -v $(pwd)/collector-config.yaml:/etc/otelcol/config.yaml otel/opentelemetry-collector |
| 97 | +``` |
| 98 | + |
| 99 | +现在,这个 Collector 已能通过 OTLP 接收遥测数据。 |
| 100 | +之后你可能需要配置 Collector,将遥测数据发送到你的可观测性后端。 |
| 101 | + |
| 102 | +{{ end }} |
0 commit comments