From e738db4df1c461643e269f3124cd9b692fe16689 Mon Sep 17 00:00:00 2001 From: Chi Ma Date: Tue, 13 Jun 2023 01:11:28 +0700 Subject: [PATCH] [frontendproxy] Add opentelemetry_collector_http to envoy's cluster and expose /oltp-http/ endpoint to frontendproxy --- .env | 7 ++++--- CHANGELOG.md | 2 ++ docker-compose.yml | 3 ++- kubernetes/opentelemetry-demo.yaml | 6 ++++-- src/frontendproxy/envoy.tmpl.yaml | 22 ++++++++++++++++++---- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 955519f76e..b454a66fe2 100644 --- a/.env +++ b/.env @@ -9,9 +9,10 @@ ENV_PLATFORM=local # OpenTelemetry Collector OTEL_COLLECTOR_HOST=otelcol -OTEL_COLLECTOR_PORT=4317 -OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT} -PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces +OTEL_COLLECTOR_PORT_GRPC=4317 +OTEL_COLLECTOR_PORT_HTTP=4318 +OTEL_EXPORTER_OTLP_ENDPOINT=http://${OTEL_COLLECTOR_HOST}:${OTEL_COLLECTOR_PORT_GRPC} +PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:8080/oltp-http/v1/traces # OpenTelemetry Resource Definitions OTEL_RESOURCE_ATTRIBUTES="service.namespace=opentelemetry-demo" diff --git a/CHANGELOG.md b/CHANGELOG.md index f8fc76de2a..7122870070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ release. ([#914](https://github.com/open-telemetry/opentelemetry-demo/pull/914)) * [cartservice] update .NET package to 1.5.0 release ([#935](https://github.com/open-telemetry/opentelemetry-demo/pull/935)) +* [frontendproxy]Envoy expose a route for the collector to route frontend spans + ([#938](https://github.com/open-telemetry/opentelemetry-demo/pull/938)) ## 1.4.0 diff --git a/docker-compose.yml b/docker-compose.yml index f06380dad6..e7ff7f92b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -330,7 +330,8 @@ services: - JAEGER_SERVICE_PORT - JAEGER_SERVICE_HOST - OTEL_COLLECTOR_HOST - - OTEL_COLLECTOR_PORT + - OTEL_COLLECTOR_PORT_GRPC + - OTEL_COLLECTOR_PORT_HTTP - ENVOY_PORT depends_on: - frontend diff --git a/kubernetes/opentelemetry-demo.yaml b/kubernetes/opentelemetry-demo.yaml index 34313a755c..8b03b7cc47 100644 --- a/kubernetes/opentelemetry-demo.yaml +++ b/kubernetes/opentelemetry-demo.yaml @@ -7761,7 +7761,7 @@ spec: - name: WEB_OTEL_SERVICE_NAME value: frontend-web - name: PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - value: http://localhost:4318/v1/traces + value: http://localhost:8080/oltp-http/v1/traces - name: OTEL_RESOURCE_ATTRIBUTES value: service.name=$(OTEL_SERVICE_NAME),service.instance.id=$(OTEL_K8S_POD_UID),service.namespace=opentelemetry-demo,k8s.namespace.name=$(OTEL_K8S_NAMESPACE),k8s.node.name=$(OTEL_K8S_NODE_NAME),k8s.pod.name=$(OTEL_K8S_POD_NAME) resources: @@ -7860,8 +7860,10 @@ spec: value: "16686" - name: JAEGER_SERVICE_HOST value: 'opentelemetry-demo-jaeger-query' - - name: OTEL_COLLECTOR_PORT + - name: OTEL_COLLECTOR_PORT_GRPC value: "4317" + - name: OTEL_COLLECTOR_PORT_HTTP + value: "4318" - name: OTEL_COLLECTOR_HOST value: $(OTEL_COLLECTOR_NAME) - name: OTEL_RESOURCE_ATTRIBUTES diff --git a/src/frontendproxy/envoy.tmpl.yaml b/src/frontendproxy/envoy.tmpl.yaml index 2eb11a5570..431f76a166 100644 --- a/src/frontendproxy/envoy.tmpl.yaml +++ b/src/frontendproxy/envoy.tmpl.yaml @@ -22,7 +22,7 @@ static_resources: "@type": type.googleapis.com/envoy.config.trace.v3.OpenTelemetryConfig grpc_service: envoy_grpc: - cluster_name: opentelemetry_collector + cluster_name: opentelemetry_collector_grpc timeout: 0.250s service_name: frontend-proxy route_config: @@ -36,6 +36,8 @@ static_resources: route: { cluster: featureflag, prefix_rewrite: "/" } - match: { prefix: "/loadgen" } route: { cluster: loadgen, prefix_rewrite: "/" } + - match: { prefix: "/oltp-http/" } + route: { cluster: opentelemetry_collector_http, prefix_rewrite: "/" } - match: { prefix: "/jaeger" } route: { cluster: jaeger } - match: { prefix: "/grafana" } @@ -48,7 +50,7 @@ static_resources: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router clusters: - - name: opentelemetry_collector + - name: opentelemetry_collector_grpc type: STRICT_DNS lb_policy: ROUND_ROBIN typed_extension_protocol_options: @@ -57,14 +59,26 @@ static_resources: explicit_http_config: http2_protocol_options: {} load_assignment: - cluster_name: opentelemetry_collector + cluster_name: opentelemetry_collector_grpc endpoints: - lb_endpoints: - endpoint: address: socket_address: address: ${OTEL_COLLECTOR_HOST} - port_value: ${OTEL_COLLECTOR_PORT} + port_value: ${OTEL_COLLECTOR_PORT_GRPC} + - name: opentelemetry_collector_http + type: STRICT_DNS + lb_policy: ROUND_ROBIN + load_assignment: + cluster_name: opentelemetry_collector_http + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: ${OTEL_COLLECTOR_HOST} + port_value: ${OTEL_COLLECTOR_PORT_HTTP} - name: frontend type: STRICT_DNS lb_policy: ROUND_ROBIN