Skip to content

Commit

Permalink
e2e: zkipin tracing test (#3748)
Browse files Browse the repository at this point in the history
* should use TCP as default protocol

Signed-off-by: zirain <[email protected]>

* support grpc

Signed-off-by: zirain <[email protected]>

* e2e: zipkin tracing test

Signed-off-by: zirain <[email protected]>

* fix service.name

Signed-off-by: zirain <[email protected]>

* lint

Signed-off-by: zirain <[email protected]>

---------

Signed-off-by: zirain <[email protected]>
  • Loading branch information
zirain committed Jul 5, 2024
1 parent b1e07ea commit eb9163a
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 5 deletions.
2 changes: 2 additions & 0 deletions charts/gateway-addons-helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ To uninstall the chart:
| opentelemetry-collector.config.processors.attributes.actions[0].value | string | `"k8s.pod.name, k8s.namespace.name"` | |
| opentelemetry-collector.config.receivers.otlp.protocols.grpc.endpoint | string | `"${env:MY_POD_IP}:4317"` | |
| opentelemetry-collector.config.receivers.otlp.protocols.http.endpoint | string | `"${env:MY_POD_IP}:4318"` | |
| opentelemetry-collector.config.receivers.zipkin.endpoint | string | `"${env:MY_POD_IP}:9411"` | |
| opentelemetry-collector.config.service.extensions[0] | string | `"health_check"` | |
| opentelemetry-collector.config.service.pipelines.logs.exporters[0] | string | `"loki"` | |
| opentelemetry-collector.config.service.pipelines.logs.processors[0] | string | `"attributes"` | |
Expand All @@ -120,6 +121,7 @@ To uninstall the chart:
| opentelemetry-collector.config.service.pipelines.metrics.receivers[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.exporters[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.receivers[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.receivers[1] | string | `"zipkin"` | |
| opentelemetry-collector.enabled | bool | `false` | |
| opentelemetry-collector.fullnameOverride | string | `"otel-collector"` | |
| opentelemetry-collector.mode | string | `"deployment"` | |
Expand Down
3 changes: 3 additions & 0 deletions charts/gateway-addons-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ opentelemetry-collector:
# Loki will convert this to k8s_pod_name label.
value: k8s.pod.name, k8s.namespace.name
receivers:
zipkin:
endpoint: ${env:MY_POD_IP}:9411
otlp:
protocols:
grpc:
Expand Down Expand Up @@ -230,3 +232,4 @@ opentelemetry-collector:
- otlp
receivers:
- otlp
- zipkin
2 changes: 2 additions & 0 deletions site/content/en/latest/install/gateway-addons-helm-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ An Add-ons Helm chart for Envoy Gateway
| opentelemetry-collector.config.processors.attributes.actions[0].value | string | `"k8s.pod.name, k8s.namespace.name"` | |
| opentelemetry-collector.config.receivers.otlp.protocols.grpc.endpoint | string | `"${env:MY_POD_IP}:4317"` | |
| opentelemetry-collector.config.receivers.otlp.protocols.http.endpoint | string | `"${env:MY_POD_IP}:4318"` | |
| opentelemetry-collector.config.receivers.zipkin.endpoint | string | `"${env:MY_POD_IP}:9411"` | |
| opentelemetry-collector.config.service.extensions[0] | string | `"health_check"` | |
| opentelemetry-collector.config.service.pipelines.logs.exporters[0] | string | `"loki"` | |
| opentelemetry-collector.config.service.pipelines.logs.processors[0] | string | `"attributes"` | |
Expand All @@ -99,6 +100,7 @@ An Add-ons Helm chart for Envoy Gateway
| opentelemetry-collector.config.service.pipelines.metrics.receivers[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.exporters[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.receivers[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.receivers[1] | string | `"zipkin"` | |
| opentelemetry-collector.enabled | bool | `false` | |
| opentelemetry-collector.fullnameOverride | string | `"otel-collector"` | |
| opentelemetry-collector.mode | string | `"deployment"` | |
Expand Down
2 changes: 2 additions & 0 deletions site/content/zh/latest/install/gateway-addons-helm-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ An Add-ons Helm chart for Envoy Gateway
| opentelemetry-collector.config.processors.attributes.actions[0].value | string | `"k8s.pod.name, k8s.namespace.name"` | |
| opentelemetry-collector.config.receivers.otlp.protocols.grpc.endpoint | string | `"${env:MY_POD_IP}:4317"` | |
| opentelemetry-collector.config.receivers.otlp.protocols.http.endpoint | string | `"${env:MY_POD_IP}:4318"` | |
| opentelemetry-collector.config.receivers.zipkin.endpoint | string | `"${env:MY_POD_IP}:9411"` | |
| opentelemetry-collector.config.service.extensions[0] | string | `"health_check"` | |
| opentelemetry-collector.config.service.pipelines.logs.exporters[0] | string | `"loki"` | |
| opentelemetry-collector.config.service.pipelines.logs.processors[0] | string | `"attributes"` | |
Expand All @@ -99,6 +100,7 @@ An Add-ons Helm chart for Envoy Gateway
| opentelemetry-collector.config.service.pipelines.metrics.receivers[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.exporters[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.receivers[0] | string | `"otlp"` | |
| opentelemetry-collector.config.service.pipelines.traces.receivers[1] | string | `"zipkin"` | |
| opentelemetry-collector.enabled | bool | `false` | |
| opentelemetry-collector.fullnameOverride | string | `"otel-collector"` | |
| opentelemetry-collector.mode | string | `"deployment"` | |
Expand Down
5 changes: 4 additions & 1 deletion test/config/gatewayclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ spec:
namespace: monitoring
port: 4317
customTags:
"provider":
type: Literal
literal:
value: "otel"
"k8s.cluster.name":
type: Literal
literal:
Expand Down Expand Up @@ -165,4 +169,3 @@ metadata:
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
---

70 changes: 70 additions & 0 deletions test/e2e/base/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec:
allowedRoutes:
namespaces:
from: All
infrastructure:
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: zipkin-tracing
namespace: envoy-gateway-system
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
Expand Down Expand Up @@ -1099,3 +1105,67 @@ spec:
protocol: TCP
port: 19001
targetPort: 19001
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: eg-special-case
namespace: gateway-conformance-infra
spec:
gatewayClassName: "{GATEWAY_CLASS_NAME}"
listeners:
- name: http
port: 80
protocol: HTTP
allowedRoutes:
namespaces:
from: All
infrastructure:
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: zipkin-tracing
---
# This is a EnvoyProxy used for Zipkin tracing and will
# target to the eg-special-case Gateway
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: zipkin-tracing
namespace: gateway-conformance-infra
spec:
logging:
level:
default: debug
telemetry:
tracing:
provider:
type: Zipkin
backendRefs:
- name: otel-collector
namespace: monitoring
port: 9411
zipkin:
enable128BitTraceId: true
customTags:
"provider":
type: Literal
literal:
value: "zipkin"
"k8s.cluster.name":
type: Literal
literal:
value: "envoy-gateway"
"k8s.pod.name":
type: Environment
environment:
name: ENVOY_POD_NAME
defaultValue: "-"
"k8s.namespace.name":
type: Environment
environment:
name: ENVOY_GATEWAY_NAMESPACE
defaultValue: "envoy-gateway-system"
shutdown:
drainTimeout: 5s
minDrainDuration: 1s
2 changes: 1 addition & 1 deletion test/e2e/testdata/tracing-otel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
- matches:
- path:
type: PathPrefix
value: /tracing
value: /otel
backendRefs:
- name: infra-backend-v1
port: 8080
16 changes: 16 additions & 0 deletions test/e2e/testdata/tracing-zipkin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: tracing-zipkin
namespace: gateway-conformance-infra
spec:
parentRefs:
- name: eg-special-case
rules:
- matches:
- path:
type: PathPrefix
value: /zipkin
backendRefs:
- name: infra-backend-v2
port: 8080
55 changes: 53 additions & 2 deletions test/e2e/tests/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

func init() {
ConformanceTests = append(ConformanceTests, OpenTelemetryTracingTest)
ConformanceTests = append(ConformanceTests, OpenTelemetryTracingTest, ZipkinTracingTest)
}

var OpenTelemetryTracingTest = suite.ConformanceTest{
Expand All @@ -49,7 +49,7 @@ var OpenTelemetryTracingTest = suite.ConformanceTest{

expectedResponse := httputils.ExpectedResponse{
Request: httputils.Request{
Path: "/tracing",
Path: "/otel",
},
Response: httputils.Response{
StatusCode: 200,
Expand All @@ -61,6 +61,7 @@ var OpenTelemetryTracingTest = suite.ConformanceTest{

tags := map[string]string{
"component": "proxy",
"provider": "otel",
"service.name": naming.ServiceName(gwNN),
}
// let's wait for the log to be sent to stdout
Expand All @@ -83,6 +84,56 @@ var OpenTelemetryTracingTest = suite.ConformanceTest{
},
}

var ZipkinTracingTest = suite.ConformanceTest{
ShortName: "ZipkinTracing",
Description: "Make sure Zipkin tracing is working",
Manifests: []string{"testdata/tracing-zipkin.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
t.Run("tempo", func(t *testing.T) {
ns := "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "tracing-zipkin", Namespace: ns}
gwNN := types.NamespacedName{Name: "eg-special-case", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)

expectedResponse := httputils.ExpectedResponse{
Request: httputils.Request{
Path: "/zipkin",
},
Response: httputils.Response{
StatusCode: 200,
},
Namespace: ns,
}
// make sure listener is ready
httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)

tags := map[string]string{
"component": "proxy",
"provider": "zipkin",
// TODO: this came from --service-cluster, which is different from OTel,
// should make them kept consistent
"service.name": fmt.Sprintf("%s/%s", gwNN.Namespace, gwNN.Name),
}
// let's wait for the log to be sent to stdout
if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute, true,
func(ctx context.Context) (bool, error) {
count, err := QueryTraceFromTempo(t, suite.Client, tags)
if err != nil {
t.Logf("failed to get trace count from tempo: %v", err)
return false, nil
}

if count > 0 {
return true, nil
}
return false, nil
}); err != nil {
t.Errorf("failed to get trace from tempo: %v", err)
}
})
},
}

// QueryTraceFromTempo queries span count from tempo
// TODO: move to utils package if needed
func QueryTraceFromTempo(t *testing.T, c client.Client, tags map[string]string) (int, error) {
Expand Down
3 changes: 2 additions & 1 deletion test/helm/gateway-addons-helm/e2e.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ data:
- batch
receivers:
- otlp
- zipkin
telemetry:
metrics:
address: ${env:MY_POD_IP}:8888
Expand Down Expand Up @@ -9956,7 +9957,7 @@ spec:
template:
metadata:
annotations:
checksum/config: 077be33cb293f9c37d065397da8156bf9f33a42ad56a3d5876f39de72c874023
checksum/config: 4eb06aca6ff4da4de927cb9ba7d8ceb883d2484011fbd670683037b8ea4d996c

labels:
app.kubernetes.io/name: opentelemetry-collector
Expand Down

0 comments on commit eb9163a

Please sign in to comment.