Skip to content

feat(product-console): add dynamic OTEL host injection support#1156

Merged
ferr3ira-gabriel merged 1 commit intodevelopfrom
feat/product-console-otel-host-injection
Apr 1, 2026
Merged

feat(product-console): add dynamic OTEL host injection support#1156
ferr3ira-gabriel merged 1 commit intodevelopfrom
feat/product-console-otel-host-injection

Conversation

@ferr3ira-gabriel
Copy link
Copy Markdown
Member

Summary

Add support for dynamic OpenTelemetry configuration using the node's HOST_IP for product-console helm chart.

Problem

The OTEL collector in firmino runs as a DaemonSet with hostPorts (no ClusterIP Service), so apps need to connect via the node's IP address. The current product-console chart only supports static configmap values.

Solution

When otel.enabled=true, the chart now injects:

  • HOST_IP from pod's status.hostIP (fieldRef)
  • OTEL_HOST = $(HOST_IP)
  • OTEL_URL_METRICS = http://$(HOST_IP):<port>/v1/metrics
  • OTEL_URL_TRACES = http://$(HOST_IP):<port>/v1/traces
  • OTEL_URL_LOGS = http://$(HOST_IP):<port>/v1/logs

This matches the pattern used by other services (midaz, flowker, etc.).

Usage

otel:
  enabled: true
  port: 4318

configmap:
  ENABLE_TELEMETRY: "true"

Testing

  • Deploy with otel.enabled=true and verify env vars are injected correctly
  • Verify logs appear in Grafana Loki after deployment

@ferr3ira-gabriel ferr3ira-gabriel requested a review from a team as a code owner April 1, 2026 02:08
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Caution

Review failed

Pull request was closed or merged during review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The Helm chart adds an otel values block (enabled, external, host, port) and removes static OTEL defaults from the ConfigMap. The deployment template validates at render time: if configmap["ENABLE_TELEMETRY"] == "true" and neither .Values.otel.enabled nor .Values.otel.external is set, rendering fails. When .Values.otel.enabled or .Values.otel.external is true, the deployment receives an injected env: block that sets OTEL_HOST and OTEL_URL_METRICS/OTEL_URL_TRACES/OTEL_URL_LOGS either from .Values.otel.host/.Values.otel.port or by deriving HOST_IP from status.hostIP and using $(HOST_IP) with the configured port.

Sequence Diagram(s)

sequenceDiagram
    participant Helm as Helm template
    participant K8sAPI as Kubernetes API
    participant Pod as Pod/Container
    participant OTEL as OpenTelemetry Collector

    Helm->>K8sAPI: Render Deployment (check ENABLE_TELEMETRY vs .Values.otel)
    alt validation fails
        Helm-->>K8sAPI: Fail rendering with error
    else validation passes
        Helm->>K8sAPI: Apply Deployment with conditional env vars
        K8sAPI->>Pod: Schedule Pod and start container
        alt otel.host provided
            K8sAPI->>Pod: Inject OTEL_HOST and OTEL_URL_* from otel.host:otel.port
            Pod->>OTEL: Send metrics/traces/logs to OTEL_URL_* (host:port)
        else use hostIP
            Pod->>Pod: Resolve HOST_IP from status.hostIP
            K8sAPI->>Pod: Inject OTEL_HOST as $(HOST_IP) and OTEL_URL_* using $(HOST_IP):port
            Pod->>OTEL: Send metrics/traces/logs to OTEL_URL_* ($(HOST_IP):port)
        end
    end
Loading
🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete, missing most required checklist items from the repository template. Complete the Midaz Pull Request Checklist by selecting the appropriate project type and checking off all verification items (testing, documentation, code standards, security, tests, etc.).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding dynamic OTEL host injection support to the product-console Helm chart.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/product-console/templates/deployment.yaml`:
- Around line 53-67: The env: line is rendered even when .Values.otel.enabled is
false, producing an invalid env: null; wrap the whole env block with the
conditional instead of just its items: move the {{- if .Values.otel.enabled }} /
{{- end }} to surround the env: key and its indented OTEL_* entries (including
the HOST_IP fieldRef and OTEL_URL_* values) so that env: is omitted entirely
when otel is disabled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4837aa67-cc9d-4c4e-8b16-18a1666c8f92

📥 Commits

Reviewing files that changed from the base of the PR and between e4aec41 and d9bc657.

📒 Files selected for processing (2)
  • charts/product-console/templates/deployment.yaml
  • charts/product-console/values.yaml

@ferr3ira-gabriel ferr3ira-gabriel force-pushed the feat/product-console-otel-host-injection branch from d9bc657 to 128bbd5 Compare April 1, 2026 02:20
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/product-console/templates/deployment.yaml`:
- Around line 53-67: The deployment template can allow ENABLE_TELEMETRY=true
while no exporter endpoints are set (OTEL_HOST/OTEL_URL_*), so add a fail-fast
check in the pod start-up: when configmap.ENABLE_TELEMETRY is "true" and both
.Values.otel.enabled and .Values.otel.external are false, exit with a clear
error. Implement this by adding a small initContainer or an entrypoint script
invoked in the Deployment template (referencing OTEL_HOST, OTEL_URL_METRICS,
OTEL_URL_TRACES, OTEL_URL_LOGS, and configmap.ENABLE_TELEMETRY) that validates
the variables and fails the pod start if endpoints are missing, returning a
descriptive error message about telemetry being enabled without configured
exporters.

In `@charts/product-console/values.yaml`:
- Around line 155-156: The comment above ENABLE_TELEMETRY mentions only
"otel.enabled=true" for dynamic injection of OTEL_HOST and OTEL_URL_*; update
that comment to also mention that "otel.external=true" triggers the same env
injection. Edit the existing note text to say: when otel.enabled=true or
otel.external=true, OTEL_HOST and OTEL_URL_* are injected dynamically from
HOST_IP so maintainers see both flags that cause injection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d620ec2f-46a9-4664-a201-5f9fe7aca4e5

📥 Commits

Reviewing files that changed from the base of the PR and between d9bc657 and 128bbd5.

📒 Files selected for processing (2)
  • charts/product-console/templates/deployment.yaml
  • charts/product-console/values.yaml

@ferr3ira-gabriel ferr3ira-gabriel force-pushed the feat/product-console-otel-host-injection branch from 128bbd5 to 7ee7ad5 Compare April 1, 2026 02:26
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
charts/product-console/values.yaml (1)

157-157: ⚠️ Potential issue | 🟡 Minor

Update the OTEL note to include otel.external=true.

Line 157 mentions only otel.enabled=true, but deployment env injection also occurs when otel.external=true.

Suggested patch
-  # Note: When otel.enabled=true, OTEL_HOST and OTEL_URL_* are injected dynamically from HOST_IP
+  # Note: When otel.enabled=true or otel.external=true, OTEL_HOST and OTEL_URL_* are injected dynamically
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/product-console/values.yaml` at line 157, Update the inline comment
that currently references only otel.enabled to also mention otel.external;
specifically, modify the note that reads "When otel.enabled=true, OTEL_HOST and
OTEL_URL_* are injected dynamically from HOST_IP" so it states that injection
happens when either otel.enabled=true or otel.external=true, keeping the
reference to OTEL_HOST, OTEL_URL_* and HOST_IP intact to clarify both flags
trigger dynamic env injection.
charts/product-console/templates/deployment.yaml (1)

53-78: ⚠️ Potential issue | 🟠 Major

Add a template fail-fast for telemetry toggle mismatch.

Line 53 currently allows rendering with configmap.ENABLE_TELEMETRY="true" while both otel.enabled and otel.external are false, leaving OTEL exporter endpoints unset.

Suggested patch
+          {{- $telemetryEnabled := eq (toString (default "false" .Values.configmap.ENABLE_TELEMETRY)) "true" -}}
+          {{- if and $telemetryEnabled (not (or .Values.otel.enabled .Values.otel.external)) -}}
+          {{- fail "configmap.ENABLE_TELEMETRY=true requires otel.enabled=true or otel.external=true" -}}
+          {{- end }}
           {{- if or .Values.otel.enabled .Values.otel.external }}
           env:
             {{- if .Values.otel.host }}
             - name: OTEL_HOST
#!/bin/bash
set -euo pipefail

chart="charts/product-console"

# Current behavior check: should render successfully but with telemetry=true and no OTEL env block.
helm template pc "$chart" \
  --set configmap.ENABLE_TELEMETRY=true \
  --set otel.enabled=false \
  --set otel.external=false >/tmp/pc.yaml

echo "Rendered with ENABLE_TELEMETRY=true and otel flags false."
echo "Expected after fix: helm template fails with explicit message."
rg -n -C2 'ENABLE_TELEMETRY|OTEL_URL_|OTEL_HOST|^\s*env:' /tmp/pc.yaml || true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/product-console/templates/deployment.yaml` around lines 53 - 78, Add a
Helm template guard in the deployment.yaml before the OTEL env block that fails
rendering when telemetry is enabled in the configmap but no OTEL exporter is
configured: check configmap.ENABLE_TELEMETRY (use toString
.Values.configmap.ENABLE_TELEMETRY to normalize) and if it equals "true" while
both .Values.otel.enabled and .Values.otel.external are false, call the Helm
fail function with a clear message; reference the existing OTEL env block and
the symbols .Values.otel.enabled, .Values.otel.external and
.Values.configmap.ENABLE_TELEMETRY so the template aborts instead of rendering
empty OTEL endpoints.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@charts/product-console/templates/deployment.yaml`:
- Around line 53-78: Add a Helm template guard in the deployment.yaml before the
OTEL env block that fails rendering when telemetry is enabled in the configmap
but no OTEL exporter is configured: check configmap.ENABLE_TELEMETRY (use
toString .Values.configmap.ENABLE_TELEMETRY to normalize) and if it equals
"true" while both .Values.otel.enabled and .Values.otel.external are false, call
the Helm fail function with a clear message; reference the existing OTEL env
block and the symbols .Values.otel.enabled, .Values.otel.external and
.Values.configmap.ENABLE_TELEMETRY so the template aborts instead of rendering
empty OTEL endpoints.

In `@charts/product-console/values.yaml`:
- Line 157: Update the inline comment that currently references only
otel.enabled to also mention otel.external; specifically, modify the note that
reads "When otel.enabled=true, OTEL_HOST and OTEL_URL_* are injected dynamically
from HOST_IP" so it states that injection happens when either otel.enabled=true
or otel.external=true, keeping the reference to OTEL_HOST, OTEL_URL_* and
HOST_IP intact to clarify both flags trigger dynamic env injection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 15fc0f7d-9713-42df-8ad2-11315768d3f5

📥 Commits

Reviewing files that changed from the base of the PR and between 128bbd5 and 7ee7ad5.

📒 Files selected for processing (2)
  • charts/product-console/templates/deployment.yaml
  • charts/product-console/values.yaml

@ferr3ira-gabriel ferr3ira-gabriel force-pushed the feat/product-console-otel-host-injection branch from 7ee7ad5 to 630312e Compare April 1, 2026 02:35
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
charts/product-console/values.yaml (1)

157-157: ⚠️ Potential issue | 🟡 Minor

Update the OTEL note to include otel.external=true.

The comment documents only otel.enabled=true, but env injection is also triggered by otel.external=true (see deployment template line 56: {{- if or .Values.otel.enabled .Values.otel.external }}).

Suggested fix
-  # Note: When otel.enabled=true, OTEL_HOST and OTEL_URL_* are injected dynamically from HOST_IP
+  # Note: When otel.enabled=true or otel.external=true, OTEL_HOST and OTEL_URL_* are injected dynamically
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/product-console/values.yaml` at line 157, The comment about dynamic
injection currently only mentions otel.enabled=true but the injection is also
triggered when otel.external=true; update the note in values.yaml to state that
OTEL_HOST and OTEL_URL_* are injected when either otel.enabled=true or
otel.external=true (i.e., reflect the template condition that checks or
.Values.otel.enabled .Values.otel.external), so readers know both flags cause
env injection.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@charts/product-console/values.yaml`:
- Line 157: The comment about dynamic injection currently only mentions
otel.enabled=true but the injection is also triggered when otel.external=true;
update the note in values.yaml to state that OTEL_HOST and OTEL_URL_* are
injected when either otel.enabled=true or otel.external=true (i.e., reflect the
template condition that checks or .Values.otel.enabled .Values.otel.external),
so readers know both flags cause env injection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7af849b7-9da8-4e8a-bce3-234e52ff1e29

📥 Commits

Reviewing files that changed from the base of the PR and between 7ee7ad5 and 630312e.

📒 Files selected for processing (2)
  • charts/product-console/templates/deployment.yaml
  • charts/product-console/values.yaml

Add support for dynamic OpenTelemetry configuration. When otel.enabled=true
OR otel.external=true, the chart injects OTEL_URL_* env vars:

- If otel.host is set: uses static host (e.g., ClusterIP Service)
- If otel.host is empty: injects HOST_IP from pod's node (for DaemonSet with hostPort)

Also adds fail-fast validation: if ENABLE_TELEMETRY is 'true' but neither
otel.enabled nor otel.external is set, helm template fails with a clear error.

This matches the pattern used by midaz chart and supports both:
- External OTEL collector with ClusterIP Service
- External OTEL collector DaemonSet with hostPort
@ferr3ira-gabriel ferr3ira-gabriel force-pushed the feat/product-console-otel-host-injection branch from 630312e to 4f473e9 Compare April 1, 2026 02:39
@ferr3ira-gabriel ferr3ira-gabriel merged commit ff43950 into develop Apr 1, 2026
2 of 3 checks passed
@ferr3ira-gabriel ferr3ira-gabriel deleted the feat/product-console-otel-host-injection branch April 1, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant