feat(detector-aws): detect Lambda availability zone metadata#3460
Open
garysassano wants to merge 1 commit intoopen-telemetry:mainfrom
Open
feat(detector-aws): detect Lambda availability zone metadata#3460garysassano wants to merge 1 commit intoopen-telemetry:mainfrom
garysassano wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
@opentelemetry/resource-detector-awscurrently detects standard AWS Lambdacloudandfaasattributes, but it does not populatecloud.availability_zone.cloud.availability_zone, so the Lambda detector can now populate it consistently with the other AWS resource detectors.Short description of the changes
AvailabilityZoneIDtocloud.availability_zone.Reasoning
This change stays close to the new Lambda platform feature and the existing detector design. The detector already reads Lambda runtime metadata from environment variables when it is running inside Lambda, so using the Lambda-provided localhost metadata endpoint for the AZ value is the smallest extension of that model.
I chose a direct HTTP call instead of using Powertools. That keeps the detector self-contained and avoids introducing a new runtime dependency on
@aws-lambda-powertools/commons, or assuming that Powertools is already present through a Lambda layer. For a generic OpenTelemetry detector library, the direct endpoint call is the safer default.The implementation stores the Lambda-provided AZ identifier as-is. Lambda returns an AZ ID such as
use1-az1, not an AZ name such asus-east-1a. That value is still useful because AZ IDs are consistent across AWS accounts, while AZ names are not.Possible optimizations
DescribeAvailabilityZones. I did not add that here because it would require additional IAM permissions, another API dependency, and would move the detector away from the value Lambda directly exposes.Testing
AWS_Lambda_nodejs24.x.npm test -w @opentelemetry/resource-detector-awscurrently fails before executing tests.References
cloud.availability_zone: https://opentelemetry.io/docs/specs/semconv/registry/attributes/cloud/#cloud-availability-zone