https://istio.io/latest/docs/tasks/observability/distributed-tracing/configurability/telemetry-api/#configuring-workload-specific-tracing-behavior
Khi các bạn cài istio thì mặc định là tracing sẽ được enable giữa workload có inject istio-proxy và giữa ingress gateway với workload có inject istio-proxy
![](https://nimtechnology.com/wp-content/uploads/2021/10/image-210.png)
1. Disable Tracing
1.1 Disable tracing a particular workload by Telemetry
apiVersion: telemetry.istio.io/v1alpha1
kind: Telemetry
metadata:
labels:
app.kubernetes.io/instance: tracing-istio
name: tracing-disable
namespace: default
spec:
selector:
matchLabels:
app: httpbin
tracing:
- disableSpanReporting: true
Giờ bạn quay lại ui jaeger ko con thấy hiện thị tracing nữa.
Bạn thấy kind Telemetry. Chỉ có version istio lớn hơn 1.10.4 mới có CustomResourceDefinition
Telemetry
![](https://nimtechnology.com/wp-content/uploads/2021/10/image-211.png)
1.2 Disable tracing Global.
![](https://nimtechnology.com/wp-content/uploads/2021/10/image-328.png)
enableTracing: false
Cái này mình dùng cho istio ver 1.9 trở vể trước.
nhưng mà cách này hơi thốn.
1.3) Disable tracing istio by envoy
https://github.com/istio/istio/issues/10875
https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto
https://github.com/istio/istio/issues/26973
https://github.com/istio/istio/issues/18169
https://github.com/istio/istio/issues/34772 -> only run istio ver 1.10
1.3.1) ingress-gateway
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
annotations:
name: disabled-tracing-gateway
namespace: istio-system
spec:
configPatches:
- applyTo: NETWORK_FILTER
match:
context: GATEWAY
listener:
filterChain:
filter:
name: envoy.http_connection_manager
patch:
operation: MERGE
value:
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
# preserve_external_request_id: true
generate_request_id: false
1.3.1.1) End-User access ingress-gateway
Nghĩ là mình mở 1 browser truy cập web
![](https://nimtechnology.com/wp-content/uploads/2021/11/image-25.png)
![](https://nimtechnology.com/wp-content/uploads/2021/10/image-361.png)
1.3.1.2) workload injected istio-proxy and access ingress-gateway
ở case này thì mình dùng 1 workload đã injected istio-proxy và thực curl vào urlwhile true; do curl -sS fleetman-webapp-1.nimtechnology.com/ip; echo; sleep 1; done
![](https://nimtechnology.com/wp-content/uploads/2021/11/image-26.png)
![](https://nimtechnology.com/wp-content/uploads/2021/11/image-27.png)
vẫn thấy tracing ở case này
1.3.1.3) workload injected istio-proxy and access service
ở case này thì mình dùng 1 workload đã injected istio-proxy và thực curl vào servicewhile true; do curl -sS httpbin-1.default.svc.cluster.local/ip; echo; sleep 1; done
![](https://nimtechnology.com/wp-content/uploads/2021/11/image-28.png)
![](https://nimtechnology.com/wp-content/uploads/2021/11/image-29.png)
1.3.2) a particular workload
comming soon
2) Configure tracing using MeshConfig and Pod annotations (update Fri, 24 Dec, 2021)
https://istio.io/latest/docs/tasks/observability/distributed-tracing/mesh-and-proxy-config/
Để cấu các thông số tracing như ý bạn muốn thì có 2 cách:
– Cấu hình trong file operator -> gen manifest và apply
– Cấu hình trong annotation của từng workload.
2.1) MeshConfig in Operator-Istio
cat <<'EOF' > tracing.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
meshConfig:
enableTracing: true
defaultConfig:
tracing:
sampling: 10
custom_tags:
my_tag_header:
header:
name: host
EOF
2.2) Pod annotations
apiVersion: apps/v1
kind: Deployment
metadata:
name: sleep
spec:
...
template:
metadata:
...
annotations:
proxy.istio.io/config: |
tracing:
sampling: 10
custom_tags:
my_tag_header:
header:
name: host
spec:
...
Hoặc bạn cũng có thể config như sau:
apiVersion: apps/v1
kind: Deployment
metadata:
name: sleep
spec:
...
template:
metadata:
...
annotations:
proxy.istio.io/config: "{'tracing' : { 'sampling': 100 } }"
spec:
...
Mình thì ko chuyên về tracing lắm, nên mình sẽ giải thích thông số mà mình có ứng dụng và mình hiểu:
sampling: 10
+ cái này đơn vị là %.
+ Nếu bạn có 100 call vào service của bạn. Nó random chọn ra 10call trong 100call để lấy mâũ (sampling) rồi generate tracing
https://dimitr.im/distributed-tracing-istio-jaeger
Mình có case ntn:
app đó dev cũng có tracing trong app và bình thường chưa inject istio thì trace_id có độ dài là 10 ký tự.
Nhưng khi mình inject istio thì trace_id mà app show là lại có độ dài 15 ký tự
–> bị lệnh về trace_id.
Để sử lý case này thì đại ca của mình config sampling: 100 cho istio gen tracing 100%
thì trace_id của app show ra trờ về độ dài là 10 ký tự.