mirror of https://github.com/istio/istio.io.git
[zh]sync observability/distributed-tracing/telemetry-api (#13027)
* sync telemetry api sync telemetry api * Update index.md * Update index.md * Update index.md
This commit is contained in:
parent
9eebb3d7cd
commit
73b8fdb576
|
@ -0,0 +1,178 @@
|
|||
---
|
||||
title: 使用 Telemetry API 配置链路追踪
|
||||
description: 如何使用 Telemetry API 配置链路追踪。
|
||||
weight: 8
|
||||
keywords: [telemetry,tracing]
|
||||
owner: istio/wg-policies-and-telemetry-maintainers
|
||||
test: yes
|
||||
---
|
||||
|
||||
Istio 提供了配置高级链路追踪选项的功能,例如采样率和向已采集的 Span 中添加自定义标签。
|
||||
本任务将向您展示如何使用 Telemetry API 自定义链路追踪选项。
|
||||
|
||||
## 开始之前{#before-you-begin}
|
||||
|
||||
1. 请确保您的应用程序按照[这里](/zh/docs/tasks/observability/distributed-tracing/overview/)所描述的方式配置链路追踪头。
|
||||
|
||||
1. 请根据您首选的追踪后端,根据[集成](/zh/docs/ops/integrations/)追踪安装指南安装适当的插件,
|
||||
并配置你的 Istio 代理将链路追踪信息发送到链路追踪部署服务端。
|
||||
|
||||
## 安装{#installation}
|
||||
|
||||
在此示例中,我们将发送跟踪信息到[`链路追踪系统 zipkin`](/zh/docs/ops/integrations/zipkin/),请确保已安装它:
|
||||
|
||||
{{< text bash >}}
|
||||
$ cat <<EOF > ./tracing.yaml
|
||||
apiVersion: install.istio.io/v1alpha1
|
||||
kind: IstioOperator
|
||||
spec:
|
||||
meshConfig:
|
||||
enableTracing: true
|
||||
defaultConfig:
|
||||
tracing: {} # disabled MeshConfig tracing options
|
||||
extensionProviders:
|
||||
# add zipkin provider
|
||||
- name: zipkin
|
||||
zipkin:
|
||||
service: zipkin.istio-system.svc.cluster.local
|
||||
port: 9411
|
||||
EOF
|
||||
$ istioctl install -f ./tracing.yaml --skip-confirmation
|
||||
{{< /text >}}
|
||||
|
||||
### 启用服务网格的链路追踪{#enable-tracing-for-mesh}
|
||||
|
||||
通过以下配置启用链路追踪:
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: telemetry.istio.io/v1alpha1
|
||||
kind: Telemetry
|
||||
metadata:
|
||||
name: mesh-default
|
||||
namespace: istio-system
|
||||
spec:
|
||||
tracing:
|
||||
- providers:
|
||||
- name: "zipkin"
|
||||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
## 自定义链路追踪采样率{#customizing-trace-sampling}
|
||||
|
||||
采样率选项可用于控制哪些请求的百分比被采集到链路追踪系统中。
|
||||
应根据服务网格中的流量和你想要收集的链路追踪数据量来配置此选项。
|
||||
默认采样率为1%。
|
||||
|
||||
{{< text bash >}}
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: telemetry.istio.io/v1alpha1
|
||||
kind: Telemetry
|
||||
metadata:
|
||||
name: mesh-default
|
||||
namespace: istio-system
|
||||
spec:
|
||||
tracing:
|
||||
- providers:
|
||||
- name: "zipkin"
|
||||
randomSamplingPercentage: 100.00
|
||||
EOF
|
||||
{{< /text >}}
|
||||
|
||||
## 自定义链路追踪标签{#customizing-tracing-tags}
|
||||
|
||||
可以基于文本、环境变量和客户端请求标头向 spans 添加自定义标签,以在与环境相关的 spans 中提供额外的信息。
|
||||
|
||||
{{< warning >}}
|
||||
添加自定义标签的数量没有限制,但标签名称必须唯一。
|
||||
{{< /warning >}}
|
||||
|
||||
您可以使用以下三种支持的选项来自定义标签。
|
||||
|
||||
1. Literal 表示一个静态的值,会被添加到每个 span 中。
|
||||
|
||||
{{< text yaml >}}
|
||||
apiVersion: telemetry.istio.io/v1alpha1
|
||||
kind: Telemetry
|
||||
metadata:
|
||||
name: mesh-default
|
||||
namespace: istio-system
|
||||
spec:
|
||||
tracing:
|
||||
- providers:
|
||||
- name: "zipkin"
|
||||
randomSamplingPercentage: 100.00
|
||||
customTags:
|
||||
"provider":
|
||||
literal:
|
||||
value: "zipkin"
|
||||
{{< /text >}}
|
||||
|
||||
1. 环境变量可以用于从工作负载代理环境中自定义标签。
|
||||
|
||||
{{< text yaml >}}
|
||||
apiVersion: telemetry.istio.io/v1alpha1
|
||||
kind: Telemetry
|
||||
metadata:
|
||||
name: mesh-default
|
||||
namespace: istio-system
|
||||
spec:
|
||||
tracing:
|
||||
- providers:
|
||||
- name: "zipkin"
|
||||
randomSamplingPercentage: 100.00
|
||||
customTags:
|
||||
"cluster_id":
|
||||
environment:
|
||||
name: ISTIO_META_CLUSTER_ID
|
||||
defaultValue: Kubernetes # optional
|
||||
{{< /text >}}
|
||||
|
||||
{{< warning >}}
|
||||
为了基于环境变量添加自定义标签,您必须修改根 Istio 系统命名空间中的 `istio-sidecar-injector` 的 ConfigMap。
|
||||
{{< /warning >}}
|
||||
|
||||
1. 客户端请求头选项可用于从传入的客户端请求头中添加标签。
|
||||
|
||||
{{< text yaml >}}
|
||||
apiVersion: telemetry.istio.io/v1alpha1
|
||||
kind: Telemetry
|
||||
metadata:
|
||||
name: mesh-default
|
||||
namespace: istio-system
|
||||
spec:
|
||||
tracing:
|
||||
- providers:
|
||||
- name: "zipkin"
|
||||
randomSamplingPercentage: 100.00
|
||||
custom_tags:
|
||||
my_tag_header:
|
||||
header:
|
||||
name: <CLIENT-HEADER>
|
||||
defaultValue: <VALUE> # optional
|
||||
{{< /text >}}
|
||||
|
||||
## 自定义链路追踪标签长度{#customizing-tracing-tag-length}
|
||||
|
||||
默认情况下,`HttpUrl` 的 span 标签的请求最大长度为256。要修改此最大长度,请将以下内容添加到您的 `tracing.yaml` 文件中。
|
||||
|
||||
{{< text yaml >}}
|
||||
apiVersion: install.istio.io/v1alpha1
|
||||
kind: IstioOperator
|
||||
spec:
|
||||
meshConfig:
|
||||
enableTracing: true
|
||||
defaultConfig:
|
||||
tracing: {} # disabled tracing options via `MeshConfig`
|
||||
extensionProviders:
|
||||
# add zipkin provider
|
||||
- name: zipkin
|
||||
zipkin:
|
||||
service: zipkin.istio-system.svc.cluster.local
|
||||
port: 9411
|
||||
maxTagLength: <VALUE>
|
||||
{{< /text >}}
|
||||
|
||||
## 验证结果{#verify-the-results}
|
||||
|
||||
您可以使用[Zipkin 界面](/zh/docs/tasks/observability/distributed-tracing/zipkin/)来验证结果。
|
Loading…
Reference in New Issue