add tracing Telemetry API tests (#12973)

* add tracing Telemetry API tests

* fix lint

* update

* update test

* remove ns

* update cleanup

* use --skip-confirmation
This commit is contained in:
zirain 2023-04-07 03:52:25 +08:00 committed by GitHub
parent cba3788c75
commit d50bef68a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 219 additions and 5 deletions

View File

@ -4,7 +4,7 @@ description: How to configure tracing options using Telemetry API.
weight: 8
keywords: [telemetry,tracing]
owner: istio/wg-policies-and-telemetry-maintainers
test: no
test: yes
---
Istio provides the ability to configure advanced tracing options,
@ -31,7 +31,7 @@ spec:
meshConfig:
enableTracing: true
defaultConfig:
tracing: {} # disabled tracing options via `MeshConfig`
tracing: {} # disabled MeshConfig tracing options
extensionProviders:
# add zipkin provider
- name: zipkin
@ -39,7 +39,7 @@ spec:
service: zipkin.istio-system.svc.cluster.local
port: 9411
EOF
$ istioctl install -f ./tracing.yaml
$ istioctl install -f ./tracing.yaml --skip-confirmation
{{< /text >}}
### Enable tracing for mesh
@ -108,9 +108,9 @@ You can customize the tags using any of the three supported options below.
- name: "zipkin"
randomSamplingPercentage: 100.00
customTags:
"provider":
"provider":
literal:
value: "zipkin"
value: "zipkin"
{{< /text >}}
1. Environmental variables can be used where the value of the custom tag is
@ -181,3 +181,7 @@ spec:
port: 9411
maxTagLength: <VALUE>
{{< /text >}}
## Verify the results
You can verify the results with [Zipkin UI](/docs/tasks/observability/distributed-tracing/zipkin/).

View File

@ -0,0 +1,139 @@
#!/bin/bash
# shellcheck disable=SC2034,SC2153,SC2155,SC2164
# Copyright Istio Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
####################################################################################################
# WARNING: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT. PLEASE MODIFY THE ORIGINAL MARKDOWN FILE:
# docs/tasks/observability/distributed-tracing/telemetry-api/index.md
####################################################################################################
snip_installation_1() {
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 --set values.pilot.env.PILOT_ENABLE_CONFIG_DISTRIBUTION_TRACKING=true -f ./tracing.yaml --skip-confirmation
}
snip_enable_tracing_for_mesh_1() {
kubectl apply -f - <<EOF
apiVersion: telemetry.istio.io/v1alpha1
kind: Telemetry
metadata:
name: mesh-default
namespace: istio-system
spec:
tracing:
- providers:
- name: "zipkin"
EOF
}
snip_customizing_trace_sampling_1() {
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
}
! read -r -d '' snip_customizing_tracing_tags_1 <<\ENDSNIP
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"
ENDSNIP
! read -r -d '' snip_customizing_tracing_tags_2 <<\ENDSNIP
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
ENDSNIP
! read -r -d '' snip_customizing_tracing_tags_3 <<\ENDSNIP
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
ENDSNIP
! read -r -d '' snip_customizing_tracing_tag_length_1 <<\ENDSNIP
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>
ENDSNIP

View File

@ -0,0 +1,71 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC2154,SC2155,SC2034
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
set -o pipefail
source "tests/util/samples.sh"
source "tests/util/addons.sh"
# @setup profile=none
snip_installation_1
_wait_for_deployment istio-system istiod
_wait_for_deployment istio-system istio-ingressgateway
## Setting up application
# Set to known setting of sidecar injection
kubectl label namespace default istio-injection=enabled --overwrite
_deploy_and_wait_for_addons zipkin
# Install Bookinfo application
startup_bookinfo_sample
snip_customizing_trace_sampling_1
istioctl dashboard zipkin &
function send_productpage_requests() {
_set_ingress_environment_variables
local GATEWAY_URL="$INGRESS_HOST:$INGRESS_PORT"
for _ in {1..10}; do
curl "http://$GATEWAY_URL/productpage" > /dev/null
done
}
send_productpage_requests
# Although test says, take a look at traces, we don't have to do that in this task
# as it is covered by an integration test in istio/istio
function access_zipkin_with_portforward() {
local zipkin_url='http://localhost:9411/zipkin/api/v2/traces?serviceName=productpage.default'
curl -s -o /dev/null -w "%{http_code}" "$zipkin_url"
}
_verify_same access_zipkin_with_portforward "200"
pgrep istioctl | xargs kill
# @cleanup
cleanup_bookinfo_sample
# TODO: Fix issue with using killall. Also why do we need to do this in setup and cleanup?
pgrep istioctl | xargs kill
_undeploy_addons zipkin
istioctl uninstall --purge -y
kubectl delete ns istio-system