feat: OpenTelemetry module integration (#9062)
* OpenTelemetry module integration * e2e test * e2e test fix * default OpentelemetryConfig * e2e values * mount otel module for otel test only * propagate IS_CHROOT * propagate IS_CHROOT e2e test * code doc * comments * golint * opentelemetry doc * zipkin * zipkin * typo * update e2e test OpenTelemetry value * use opentelemetry value * revert merge conflict * fix * format * review comments * clean
This commit is contained in:
parent
c075793ae5
commit
c8cb9167d3
23 changed files with 1131 additions and 2 deletions
119
test/e2e/settings/opentelemetry.go
Normal file
119
test/e2e/settings/opentelemetry.go
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
Copyright 2022 The Kubernetes 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.
|
||||
*/
|
||||
|
||||
package settings
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
const (
|
||||
enableOpentelemetry = "enable-opentelemetry"
|
||||
opentelemetryTrustIncomingSpan = "opentelemetry-trust-incoming-span"
|
||||
|
||||
opentelemetryOperationName = "opentelemetry-operation-name"
|
||||
opentelemetryLocationOperationName = "opentelemetry-location-operation-name"
|
||||
opentelemetryConfig = "opentelemetry-config"
|
||||
opentelemetryConfigPath = "/etc/nginx/opentelemetry.toml"
|
||||
)
|
||||
|
||||
var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
|
||||
f := framework.NewDefaultFramework("enable-opentelemetry")
|
||||
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
})
|
||||
|
||||
ginkgo.AfterEach(func() {
|
||||
})
|
||||
|
||||
ginkgo.It("should not exists opentelemetry directive", func() {
|
||||
config := map[string]string{}
|
||||
config[enableOpentelemetry] = "false"
|
||||
f.SetNginxConfigMapData(config)
|
||||
|
||||
f.EnsureIngress(framework.NewSingleIngress(enableOpentelemetry, "/", enableOpentelemetry, f.Namespace, "http-svc", 80, nil))
|
||||
|
||||
f.WaitForNginxConfiguration(
|
||||
func(cfg string) bool {
|
||||
return !strings.Contains(cfg, "opentelemetry on")
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.It("should exists opentelemetry directive when is enabled", func() {
|
||||
config := map[string]string{}
|
||||
config[enableOpentelemetry] = "true"
|
||||
config[opentelemetryConfig] = opentelemetryConfigPath
|
||||
f.SetNginxConfigMapData(config)
|
||||
|
||||
f.EnsureIngress(framework.NewSingleIngress(enableOpentelemetry, "/", enableOpentelemetry, f.Namespace, "http-svc", 80, nil))
|
||||
|
||||
f.WaitForNginxConfiguration(
|
||||
func(cfg string) bool {
|
||||
return strings.Contains(cfg, "opentelemetry on")
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.It("should include opentelemetry_trust_incoming_spans on directive when enabled", func() {
|
||||
config := map[string]string{}
|
||||
config[enableOpentelemetry] = "true"
|
||||
config[opentelemetryConfig] = opentelemetryConfigPath
|
||||
config[opentelemetryTrustIncomingSpan] = "true"
|
||||
f.SetNginxConfigMapData(config)
|
||||
|
||||
f.EnsureIngress(framework.NewSingleIngress(enableOpentelemetry, "/", enableOpentelemetry, f.Namespace, "http-svc", 80, nil))
|
||||
|
||||
f.WaitForNginxConfiguration(
|
||||
func(cfg string) bool {
|
||||
return strings.Contains(cfg, "opentelemetry_trust_incoming_spans on")
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.It("should not exists opentelemetry_operation_name directive when is empty", func() {
|
||||
config := map[string]string{}
|
||||
config[enableOpentelemetry] = "true"
|
||||
config[opentelemetryConfig] = opentelemetryConfigPath
|
||||
config[opentelemetryOperationName] = ""
|
||||
f.SetNginxConfigMapData(config)
|
||||
|
||||
f.EnsureIngress(framework.NewSingleIngress(enableOpentelemetry, "/", enableOpentelemetry, f.Namespace, "http-svc", 80, nil))
|
||||
|
||||
f.WaitForNginxConfiguration(
|
||||
func(cfg string) bool {
|
||||
return !strings.Contains(cfg, "opentelemetry_operation_name")
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.It("should exists opentelemetry_operation_name directive when is configured", func() {
|
||||
config := map[string]string{}
|
||||
config[enableOpentelemetry] = "true"
|
||||
config[opentelemetryConfig] = opentelemetryConfigPath
|
||||
config[opentelemetryOperationName] = "HTTP $request_method $uri"
|
||||
f.SetNginxConfigMapData(config)
|
||||
|
||||
f.EnsureIngress(framework.NewSingleIngress(enableOpentelemetry, "/", enableOpentelemetry, f.Namespace, "http-svc", 80, nil))
|
||||
|
||||
f.WaitForNginxConfiguration(
|
||||
func(cfg string) bool {
|
||||
return strings.Contains(cfg, `opentelemetry_operation_name "HTTP $request_method $uri"`)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue