Skip to content

Comments

feat(lambda): read cloud.account.id from symlink in Lambda detector#4183

Open
RaphaelManke wants to merge 5 commits intoopen-telemetry:mainfrom
RaphaelManke:feat/cloud-account-id-symlink
Open

feat(lambda): read cloud.account.id from symlink in Lambda detector#4183
RaphaelManke wants to merge 5 commits intoopen-telemetry:mainfrom
RaphaelManke:feat/cloud-account-id-symlink

Conversation

@RaphaelManke
Copy link

@RaphaelManke RaphaelManke commented Feb 9, 2026

Summary

  • Reads cloud.account.id from the symlink at /tmp/.otel-aws-account-id created by the OTel Lambda Extension
  • Uses os.readlink() to read the symlink target (the AWS account ID)
  • Logs at debug level if the symlink doesn't exist (except OSError guard)

Depends on

Changes

  • _lambda.py — Added readlink logic with _ACCOUNT_ID_SYMLINK_PATH constant
  • Tests: happy path, leading zeros preserved, missing symlink handled gracefully

Test plan

  • Unit test: symlink exists → cloud.account.id set correctly
  • Unit test: leading zeros preserved as string
  • Unit test: missing symlink → attribute absent, no error

…etector

Read /tmp/.otel-account-id via os.readlink() and set the
cloud.account.id resource attribute when the symlink exists.
Silently skip when the symlink is absent (OSError caught).
@RaphaelManke RaphaelManke force-pushed the feat/cloud-account-id-symlink branch from 4bdf2ac to c63fde7 Compare February 18, 2026 06:40
@RaphaelManke RaphaelManke force-pushed the feat/cloud-account-id-symlink branch from c63fde7 to 0f57fbc Compare February 18, 2026 06:43
@RaphaelManke RaphaelManke marked this pull request as ready for review February 19, 2026 08:03
@RaphaelManke RaphaelManke requested a review from a team as a code owner February 19, 2026 08:03
@tammy-baylis-swi tammy-baylis-swi moved this to Ready for review in @xrmx's Python PR digest Feb 19, 2026
@tammy-baylis-swi
Copy link
Contributor

Thanks for this! Please do these for lint/formatting and commit the fixes:

  • tox -e lint-sdk-extension-aws
  • tox -e precommit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

3 participants