From 3d83a718c41e249e88ca462b4fa36c5a6c005a3f Mon Sep 17 00:00:00 2001 From: minherz Date: Tue, 23 Jan 2024 07:57:18 -0800 Subject: [PATCH] fix: display service name in Cloud Trace inject OTel service name env variable to enable display of service name in Cloud Trace --- helm-chart/templates/checkoutservice.yaml | 16 ++++++++++++++++ helm-chart/templates/currencyservice.yaml | 16 ++++++++++++++++ helm-chart/templates/emailservice.yaml | 16 ++++++++++++++++ helm-chart/templates/frontend.yaml | 16 ++++++++++++++++ helm-chart/templates/paymentservice.yaml | 16 ++++++++++++++++ helm-chart/templates/productcatalogservice.yaml | 16 ++++++++++++++++ helm-chart/templates/recommendationservice.yaml | 16 ++++++++++++++++ .../google-cloud-operations/kustomization.yaml | 14 ++++++++++++++ 8 files changed, 126 insertions(+) diff --git a/helm-chart/templates/checkoutservice.yaml b/helm-chart/templates/checkoutservice.yaml index 48aae406fd5..ee33d612723 100644 --- a/helm-chart/templates/checkoutservice.yaml +++ b/helm-chart/templates/checkoutservice.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.checkoutService.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -77,6 +91,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.checkoutService.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/helm-chart/templates/currencyservice.yaml b/helm-chart/templates/currencyservice.yaml index a303570b9bf..aadd1762fc9 100644 --- a/helm-chart/templates/currencyservice.yaml +++ b/helm-chart/templates/currencyservice.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.currencyService.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -61,6 +75,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.currencyService.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/helm-chart/templates/emailservice.yaml b/helm-chart/templates/emailservice.yaml index bd8f368f417..da4261dd452 100644 --- a/helm-chart/templates/emailservice.yaml +++ b/helm-chart/templates/emailservice.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.emailService.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -60,6 +74,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.emailService.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/helm-chart/templates/frontend.yaml b/helm-chart/templates/frontend.yaml index efb02a55081..7a1864c4b9b 100644 --- a/helm-chart/templates/frontend.yaml +++ b/helm-chart/templates/frontend.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.frontend.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -93,6 +107,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.frontend.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/helm-chart/templates/paymentservice.yaml b/helm-chart/templates/paymentservice.yaml index 3c983951bea..b4f58141cb1 100644 --- a/helm-chart/templates/paymentservice.yaml +++ b/helm-chart/templates/paymentservice.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.paymentService.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -60,6 +74,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.paymentService.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/helm-chart/templates/productcatalogservice.yaml b/helm-chart/templates/productcatalogservice.yaml index e92d7821287..452c57f245a 100644 --- a/helm-chart/templates/productcatalogservice.yaml +++ b/helm-chart/templates/productcatalogservice.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.productCatalogService.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -60,6 +74,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.productCatalogService.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/helm-chart/templates/recommendationservice.yaml b/helm-chart/templates/recommendationservice.yaml index e4ecc2dcce5..e526354daae 100644 --- a/helm-chart/templates/recommendationservice.yaml +++ b/helm-chart/templates/recommendationservice.yaml @@ -1,3 +1,17 @@ +# Copyright 2024 Google LLC +# +# 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 +# +# https://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. + {{- if .Values.recommendationService.create }} {{- if .Values.serviceAccounts.create }} apiVersion: v1 @@ -70,6 +84,8 @@ spec: {{- if .Values.opentelemetryCollector.create }} - name: COLLECTOR_SERVICE_ADDR value: "{{ .Values.opentelemetryCollector.name }}:4317" + - name: OTEL_SERVICE_NAME + value: "{{ .Values.recommendationService.name }}" {{- end }} {{- if .Values.googleCloudOperations.tracing }} - name: ENABLE_TRACING diff --git a/kustomize/components/google-cloud-operations/kustomization.yaml b/kustomize/components/google-cloud-operations/kustomization.yaml index e975c7ad8bf..e9980947a89 100644 --- a/kustomize/components/google-cloud-operations/kustomization.yaml +++ b/kustomize/components/google-cloud-operations/kustomization.yaml @@ -32,6 +32,8 @@ patches: env: - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "checkoutservice" - name: ENABLE_TRACING value: "1" - name: ENABLE_PROFILER @@ -50,6 +52,8 @@ patches: env: - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "currencyservice" - name: ENABLE_TRACING value: "1" - name: DISABLE_PROFILER @@ -68,6 +72,8 @@ patches: env: - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "emailservice" - name: ENABLE_TRACING value: "1" - name: DISABLE_PROFILER @@ -88,6 +94,8 @@ patches: value: "1" - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "frontend" - name: ENABLE_PROFILER value: "1" # paymentservice - tracing, profiler @@ -104,6 +112,8 @@ patches: env: - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "paymentservice" - name: ENABLE_TRACING value: "1" - name: DISABLE_PROFILER @@ -122,6 +132,8 @@ patches: env: - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "productcatalogservice" - name: ENABLE_TRACING value: "1" - name: DISABLE_PROFILER @@ -140,6 +152,8 @@ patches: env: - name: COLLECTOR_SERVICE_ADDR value: "opentelemetrycollector:4317" + - name: OTEL_SERVICE_NAME + value: "recommendationservice" - name: ENABLE_TRACING value: "1" - name: DISABLE_PROFILER