Add cloud.account.id resource attribute to language wrapper scripts#2157
Add cloud.account.id resource attribute to language wrapper scripts#2157RaphaelManke wants to merge 5 commits intoopen-telemetry:mainfrom
Conversation
Read the AWS account ID from the symlink written by the collector extension during registration (/tmp/.otel-aws-account-id, introduced in open-telemetry#2127) and append it as cloud.account.id to OTEL_RESOURCE_ATTRIBUTES in the language-specific wrapper scripts. This ensures the account ID is available as a resource attribute on telemetry produced by the language SDKs (Node.js, Java, Python, Ruby), since the wrapper scripts execute after the extension has registered and created the symlink.
wpessers
left a comment
There was a problem hiding this comment.
Looks good 🚀 I'll be awaiting the results of your testing to make sure since you added the testing plan with open tasks to this PR.
|
Tested it and works as expected. |
|
the check-links action failure is unrelated to your pr, seems like the I can fix it if you want, or if you'd rather do it yourself that's fine too. Up to you 😄 |
|
So if you prefer keeping the link to that pr in there, that's fine btw @RaphaelManke. It seems like it's just the changed config var name in lychee that is causing this to fail. |
|
No, its fine without the link 😃 |
| fi | ||
|
|
||
| CLOUD_ACCOUNT_ID=$(readlink /tmp/.otel-aws-account-id 2>/dev/null || true) | ||
| if [ -n "$CLOUD_ACCOUNT_ID" ]; then |
There was a problem hiding this comment.
Is there a reason we are deviating from the strategy above for initializing the resource attributes? Generally, I think that the single if statement is a bit more readable.
Summary
/tmp/.otel-aws-account-idsymlink (created by the collector extension during registration, see feat(lambda): write cloud.account.id symlink from extension #2127) in each language's wrapper scriptcloud.account.idas a resource attribute toOTEL_RESOURCE_ATTRIBUTESif not already setHow it works
Key insight: The extension always registers before the runtime starts, so the symlink is guaranteed to exist by the time the wrapper script runs.
Motivation
The collector extension writes the AWS account ID as a symlink during registration (#2127). Since the language-specific wrapper scripts (
otel-handler/otel-instrument) execute after the extension has registered, they can reliably read this symlink and propagate the account ID to the language SDKs viaOTEL_RESOURCE_ATTRIBUTES.This ensures
cloud.account.idis present on all telemetry signals produced by the language SDKs without requiring users to manually configure it.Test plan
cloud.account.idappears on spans/logs/metrics for each language runtimecloud.account.idis already set inOTEL_RESOURCE_ATTRIBUTES, it is not overwritten