Skip to content

Comments

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

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

feat(lambda): read cloud.account.id from symlink in Lambda detector#2619
RaphaelManke wants to merge 6 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 Files.readSymbolicLink() to read the symlink target
  • Logs at FINE level if the symlink doesn't exist (catch IOException | UnsupportedOperationException)

Depends on

Changes

  • LambdaResource.java — Added readlink logic with ACCOUNT_ID_SYMLINK_PATH constant, injectable Path for testing
  • LambdaResourceTest.java — Happy path, missing symlink, leading zeros tests

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

…ector

Read /tmp/.otel-account-id via Files.readSymbolicLink in LambdaResource
and set cloud.account.id resource attribute. Silently skips if the
symlink does not exist or readlink is unsupported. Preserves leading
zeros by treating the value as a string.
@github-actions github-actions bot requested review from srprash and wangzlei February 9, 2026 20:14
@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
Copilot AI review requested due to automatic review settings February 19, 2026 08:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for reading the AWS account ID from a symlink created by the OpenTelemetry Lambda Extension. The Lambda resource detector now reads cloud.account.id from /tmp/.otel-aws-account-id, enabling automatic population of this attribute without requiring environment variables.

Changes:

  • Added symlink reading logic to LambdaResource with graceful error handling
  • Introduced injectable Path parameter for testability while maintaining backward compatibility
  • Added comprehensive unit tests covering happy path, missing symlink, and leading zero preservation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/LambdaResource.java Added symlink reading logic with proper error handling, maintained backward compatibility with existing buildResource() method signature
aws-resources/src/test/java/io/opentelemetry/contrib/aws/resource/LambdaResourceTest.java Added three test cases covering symlink reading success, missing symlink graceful handling, and leading zero preservation
CHANGELOG.md Documented the new feature under the Unreleased section

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.

1 participant