Skip to content
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

Fix K8s attributes values in OTEL_RESOURCE_ATTRIBUTES env var #864

Merged

Conversation

mat-rumian
Copy link
Contributor

@mat-rumian mat-rumian commented May 11, 2022

Move OTEL_RESOURCE_ATTRIBUTES to last position on env list.
When OTEL_RESOURCE_ATTRIBUTES environment variable uses other env vars as attributes value they have to be configured before. It is mandatory to set right order to avoid attributes with value pointing to the name of used environment variable instead of its value.

Correct order of env vars

env:
 - name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
   valueFrom:
     fieldRef:
       fieldPath: spec.nodeName
 - name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
   valueFrom:
     fieldRef:
       fieldPath: metadata.name
 - name: OTEL_RESOURCE_ATTRIBUTES
   value: k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME),k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)

This PR fixes: #793

@mat-rumian mat-rumian requested a review from a team May 11, 2022 15:00
Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

Few nits, but the approach looks good. Also the CI failed.

pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Show resolved Hide resolved
pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Show resolved Hide resolved
@pavolloffay pavolloffay merged commit a02d99c into open-telemetry:main May 13, 2022
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
…elemetry#864)

* chore(env-vars): move otel resource attributes to last env on the list

* chore(sdk-test): move otel resource attributes to last env on the list

* chore(e2e-test): update env order

* chore(env-vars): add condition, update comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Instrumentation] K8s metadata not set for some tags
2 participants