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

read resource attributes from annotations #3204

Merged

Conversation

zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Aug 7, 2024

Fixes #3112

Testing: Added integration test

Documentation: will be added to https://opentelemetry.io/docs/kubernetes/operator/automatic/ once released

@jaronoff97
Copy link
Contributor

per our discussion, @zeitlinger will rebase and expand on the capabilities introduced by #2330 :)

@zeitlinger zeitlinger force-pushed the resource-attribute-from-annotations branch from cfe0591 to a2f5aa4 Compare August 7, 2024 17:27
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

Can you also update the README.md, explaining the changes and also explaining the precedence of deciding these variables?

pkg/instrumentation/sdk_test.go Outdated Show resolved Hide resolved
@zeitlinger zeitlinger force-pushed the resource-attribute-from-annotations branch from 5edb85e to 220650b Compare August 12, 2024 09:44
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

@zeitlinger last thing – can you update the README.md with some more information about the new behavior? Maybe also include it in the subtext of the chlog entry

pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
@zeitlinger
Copy link
Member Author

@zeitlinger last thing – can you update the README.md with some more information about the new behavior? Maybe also include it in the subtext of the chlog entry

done

@zeitlinger zeitlinger force-pushed the resource-attribute-from-annotations branch 2 times, most recently from 8745d54 to baf151c Compare August 30, 2024 12:45
@pavolloffay
Copy link
Member

CI failed

@zeitlinger zeitlinger force-pushed the resource-attribute-from-annotations branch from 20c4bb7 to a273927 Compare August 30, 2024 15:16
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
apis/v1alpha1/instrumentation_types.go Outdated Show resolved Hide resolved
pkg/instrumentation/apachehttpd.go Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
@zeitlinger
Copy link
Member Author

@jaronoff97 please check again

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

another thought, also if we could add something in to an existing e2e test that would be great :) thank you! FWIW, i do think I will be taking on a refactor to make this logic a bit more straightforward in the future.

README.md Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Show resolved Hide resolved
@zeitlinger zeitlinger force-pushed the resource-attribute-from-annotations branch from a7c7322 to cc6338a Compare September 3, 2024 11:12
@zeitlinger zeitlinger force-pushed the resource-attribute-from-annotations branch from cc6338a to 2e9f6ec Compare September 4, 2024 06:34
@zeitlinger
Copy link
Member Author

another thought, also if we could add something in to an existing e2e test that would be great :)

done @jaronoff97

pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
pkg/instrumentation/sdk.go Outdated Show resolved Hide resolved
for k, v := range pod.Annotations {
if strings.HasPrefix(k, constants.ResourceAttributeAnnotationPrefix) {
k = strings.TrimPrefix(k, constants.ResourceAttributeAnnotationPrefix)
if !existingRes[k] && k != string(semconv.ServiceNameKey) {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we want to let the override happen here?

Copy link
Member Author

Choose a reason for hiding this comment

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

we treat the user defined enviroment variables as the highest priority - otherwise it would be a breaking change.
Not sure if it would also be surprising.

https://github.com/zeitlinger/opentelemetry-operator/blob/c1966659f203516c87991715c95f1dc00a372aa1/README.md?plain=1#L783

@zeitlinger
Copy link
Member Author

@jaronoff97 please check again

@@ -259,7 +529,7 @@ func TestSDKInjection(t *testing.T) {
Env: []corev1.EnvVar{
{
Name: "OTEL_SERVICE_NAME",
Value: "explicitly_set",
Value: "explicit-name",
Copy link
Contributor

Choose a reason for hiding this comment

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

OOC – why change this for the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

to make sure it's coming from the right place

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

two minor questions, neither blocking. overall i think this looks good. Going to wait on @TylerHelmuth's review before merging.

endpoint: http://localhost:4317
defaults:
useLabelsForResourceAttributes: true
Copy link
Member

Choose a reason for hiding this comment

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

Please add a new test with this flag set, I'd like to preserve the test that uses the existing behavior

Copy link
Member Author

Choose a reason for hiding this comment

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

@zeitlinger zeitlinger requested a review from a team as a code owner September 25, 2024 15:21
@swiatekm swiatekm merged commit e82f595 into open-telemetry:main Sep 25, 2024
33 checks passed
@jaronoff97
Copy link
Contributor

@zeitlinger thank you for your contribution! 🙇

@zeitlinger zeitlinger deleted the resource-attribute-from-annotations branch September 26, 2024 07:30
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.

Add support for k8s labels such as app.kubernetes.io/name
5 participants