⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@RaphaelManke
Copy link

Summary

  • Reads cloud.account.id from the symlink at /tmp/.otel-account-id created by the OTel Lambda Extension
  • Uses os.readlink() to read the symlink target (the AWS account ID)
  • Fails silently via except OSError: pass if the symlink doesn't exist

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).
symlink_path = None
try:
tmpdir = tempfile.mkdtemp()
symlink_path = os.path.join(tmpdir, ".otel-account-id")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just make this a fixture, preferably one that uses the existing tmp_path fixture from Pytest?

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.

2 participants