Skip to content

K8s: Helm config customLabels to add more tracing resource attributes #2858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Jun 7, 2025

User description

Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Fixes #2839

image

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

enhancement


Description

  • Add customLabels support to all Helm chart resources

    • Allows overriding or adding Kubernetes labels globally
  • Propagate custom labels as OpenTelemetry resource attributes

    • Injects merged labels into SE_OTEL_RESOURCE_ATTRIBUTES for tracing
  • Refactor templates to centralize label handling

    • Removes duplicate label merging logic from individual templates
  • Update documentation for new label and tracing behavior


Changes walkthrough 📝

Relevant files
Enhancement
53 files
_helpers.tpl
Inject tracing attributes and refactor label handling       
+3/-4     
_nameHelpers.tpl
Centralize and merge custom label logic for resources       
+22/-5   
basic-auth-secret.yaml
Use centralized label merging for secrets                               
+0/-3     
chrome-node-deployment.yaml
Use merged labels and inject tracing attributes                   
+0/-3     
chrome-node-hpa.yaml
Use centralized label merging for HPA                                       
+0/-3     
chrome-node-scaledjobs.yaml
Use centralized label merging for scaled jobs                       
+0/-3     
distributor-configmap.yaml
Use centralized label merging for configmap                           
+1/-4     
distributor-deployment.yaml
Use merged labels and inject tracing attributes                   
+3/-4     
distributor-service.yaml
Use centralized label merging for service                               
+1/-4     
edge-node-deployment.yaml
Use merged labels for edge node deployment                             
+0/-3     
edge-node-hpa.yaml
Use centralized label merging for edge node HPA                   
+0/-3     
edge-node-scaledjob.yaml
Use centralized label merging for edge node scaled job     
+0/-3     
event-bus-configmap.yaml
Use centralized label merging for event bus configmap       
+1/-4     
event-bus-deployment.yaml
Use merged labels and inject tracing attributes                   
+3/-4     
event-bus-service.yaml
Use centralized label merging for event bus service           
+1/-4     
firefox-node-deployment.yaml
Use merged labels for firefox node deployment                       
+0/-3     
firefox-node-hpa.yaml
Use centralized label merging for firefox node HPA             
+0/-3     
firefox-node-scaledjob.yaml
Use centralized label merging for firefox node scaled job
+0/-3     
hub-deployment.yaml
Use merged labels and inject tracing attributes                   
+3/-4     
hub-service.yaml
Use centralized label merging for hub service                       
+1/-4     
ingress.yaml
Use centralized label merging for ingress                               
+1/-4     
jaeger-ingress.yaml
Use centralized label merging for Jaeger ingress                 
+1/-4     
logging-configmap.yaml
Use centralized label merging for logging configmap           
+1/-4     
monitoring-exporter-deployment.yaml
Use centralized label merging for monitoring exporter deployment
+1/-1     
monitoring-exporter-service.yaml
Use centralized label merging for monitoring exporter service
+1/-1     
monitoring-scape-secret.yaml
Use centralized label merging for monitoring scrape secret
+0/-3     
node-configmap.yaml
Use centralized label merging for node configmap                 
+1/-4     
delete-keda-objects-job.yaml
Use centralized label merging for KEDA delete job               
+0/-3     
patch-keda-objects-cm.yaml
Use centralized label merging for KEDA patch configmap     
+0/-3     
patch-keda-objects-job.yaml
Use centralized label merging for KEDA patch job                 
+0/-3     
rbac-role.yaml
Use centralized label merging for KEDA RBAC role                 
+0/-3     
rbac-rolebinding.yaml
Use centralized label merging for KEDA RBAC rolebinding   
+0/-3     
recorder-configmap.yaml
Use centralized label merging for recorder configmap         
+1/-4     
relay-node-deployment.yaml
Use merged labels for relay node deployment                           
+0/-3     
relay-node-hpa.yaml
Use centralized label merging for relay node HPA                 
+0/-3     
relay-node-scaledjobs.yaml
Use centralized label merging for relay node scaled jobs 
+0/-3     
router-configmap.yaml
Use centralized label merging for router configmap             
+1/-4     
router-deployment.yaml
Use merged labels and inject tracing attributes                   
+3/-4     
router-service.yaml
Use centralized label merging for router service                 
+1/-4     
secrets.yaml
Use centralized label merging for secrets                               
+1/-4     
server-configmap.yaml
Use centralized label merging for server configmap             
+1/-4     
serviceaccount.yaml
Use centralized label merging for service account               
+1/-4     
session-map-configmap.yaml
Use centralized label merging for session map configmap   
+1/-4     
session-map-deployment.yaml
Use merged labels and inject tracing attributes                   
+3/-4     
session-map-service.yaml
Use centralized label merging for session map service       
+1/-4     
session-queue-configmap.yaml
Use centralized label merging for session queue configmap
+1/-4     
session-queue-deployment.yaml
Use merged labels and inject tracing attributes                   
+3/-4     
session-queue-service.yaml
Use centralized label merging for session queue service   
+1/-4     
tls-cert-secret.yaml
Use centralized label merging for TLS secret                         
+1/-4     
uploader-configmap.yaml
Use centralized label merging for uploader configmap         
+1/-4     
file-browser-deployment.yaml
Use centralized label merging for video manager deployment
+1/-4     
file-browser-ingress.yaml
Use centralized label merging for video manager ingress   
+1/-4     
file-browser-service.yaml
Use centralized label merging for video manager service   
+1/-4     
Documentation
2 files
CONFIGURATION.md
Update documentation for customLabels usage                           
+1/-1     
values.yaml
Update customLabels documentation for new behavior             
+1/-1     
Tests
1 files
simplex-docker-desktop.yaml
Add test values for customLabels and tracing                         
+8/-0     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
    Copy link

    qodo-merge-pro bot commented Jun 7, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    2839 - Fully compliant

    Compliant requirements:

    • Allow setting additional tags/attributes for APM data/OpenTelemetry data in Kubernetes
    • Support environment name and version in APM traces
    • Enable passing properties like deployment.environment and service.version
    • Ensure OTEL_RESOURCE_ATTRIBUTES are properly propagated to the containers
    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Potential Attribute Format

    The tracing attributes function joins labels with commas but doesn't handle values containing commas or spaces, which could cause parsing issues. Consider URL encoding or quoting values that might contain special characters.

    {{- define "seleniumGrid.tracing.attributes" -}}
    {{- $labels := include "seleniumGrid.commonLabels" $ | fromYaml }}
    {{- $attrs := list }}
    {{- range $k, $v := $labels }}
    {{- $attrs = append $attrs (printf "%s=%s" $k $v) }}
    {{- end }}
    {{- join "," $attrs }}
    {{- end -}}
    Parameter Passing

    The PR changes parameter passing from . to $ in many templates. Verify this doesn't break variable scope in any templates, especially in nested or included templates.

    {{- include "seleniumGrid.commonLabels" $ | nindent 6 }}
    {{- with .node.labels }}

    Copy link

    qodo-merge-pro bot commented Jun 7, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Escape special characters in attributes

    The current implementation doesn't handle values containing commas or special
    characters properly, which could break the attribute formatting. Add proper
    escaping for attribute values to ensure they're correctly formatted for
    OpenTelemetry resource attributes.

    charts/selenium-grid/templates/_helpers.tpl [50-57]

     {{- define "seleniumGrid.tracing.attributes" -}}
     {{- $labels := include "seleniumGrid.commonLabels" $ | fromYaml }}
     {{- $attrs := list }}
     {{- range $k, $v := $labels }}
    +{{- /* Quote values that contain commas or spaces to ensure proper formatting */}}
    +{{- if or (contains "," (toString $v)) (contains " " (toString $v)) }}
    +{{- $attrs = append $attrs (printf "%s=\"%s\"" $k $v) }}
    +{{- else }}
     {{- $attrs = append $attrs (printf "%s=%s" $k $v) }}
    +{{- end }}
     {{- end }}
     {{- join "," $attrs }}
     {{- end -}}

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly identifies a potential issue with OpenTelemetry attribute formatting when label values contain commas or spaces. Adding proper escaping prevents parsing errors in observability systems.

    Low
    • More

    @VietND96 VietND96 merged commit c06d1a2 into trunk Jun 7, 2025
    28 checks passed
    @VietND96 VietND96 deleted the chart-tracing-attributes branch June 7, 2025 10:02
    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.

    [🚀 Feature]: I should be allowed to set additional Tags for APM data/ Opentelemetry data in Kubernetes
    1 participant