Skip to content

Commit

Permalink
AWS ECS detector: add support for cloud.resource_id (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmanciop authored Feb 15, 2024
1 parent 5e8357b commit 9e25568
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Aws/src/Ecs/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function __construct(
*
* - cloud.account.id => <account_id> , e.g., '111122223333'
* - cloud.availability_zone => <availability_zone> , e.g., 'us-east-1a'
* - cloud.region => <availability_zone> , e.g., 'us-east-1'
* - cloud.region => <region> , e.g., 'us-east-1'
* - cloud.resource_id => <aws.ecs.container.arn> (see https://github.com/open-telemetry/semantic-conventions/issues/677)
* - aws.ecs.container.arn
* - aws.ecs.cluster.arn
* - aws.ecs.launchtype
Expand Down Expand Up @@ -232,6 +233,7 @@ private function getMetadataEndpointV4Resource(): ResourceInfo
}

$ecsResource = ResourceInfo::create(Attributes::create([
ResourceAttributes::CLOUD_RESOURCE_ID => $containerArn,
ResourceAttributes::AWS_ECS_CONTAINER_ARN => $containerArn,
ResourceAttributes::AWS_ECS_CLUSTER_ARN => $clusterArn,
ResourceAttributes::AWS_ECS_LAUNCHTYPE => $launchType,
Expand Down
3 changes: 3 additions & 0 deletions src/Aws/tests/Unit/Ecs/DetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public function TestV4ResourceLaunchTypeEc2()
ResourceAttributes::CLOUD_ACCOUNT_ID => '111122223333',
ResourceAttributes::CLOUD_AVAILABILITY_ZONE => 'us-west-2d',
ResourceAttributes::CLOUD_REGION => 'us-west-2',
ResourceAttributes::CLOUD_RESOURCE_ID => 'arn:aws:ecs:us-west-2:111122223333:container/0206b271-b33f-47ab-86c6-a0ba208a70a9',
ResourceAttributes::AWS_ECS_CONTAINER_ARN => 'arn:aws:ecs:us-west-2:111122223333:container/0206b271-b33f-47ab-86c6-a0ba208a70a9',
ResourceAttributes::AWS_ECS_CLUSTER_ARN => 'arn:aws:ecs:us-west-2:111122223333:cluster/default',
ResourceAttributes::AWS_ECS_LAUNCHTYPE => 'ec2',
Expand Down Expand Up @@ -372,6 +373,7 @@ public function TestV4ResourceLaunchTypeFargate()
ResourceAttributes::CLOUD_ACCOUNT_ID => '111122223333',
ResourceAttributes::CLOUD_AVAILABILITY_ZONE => 'us-west-2a',
ResourceAttributes::CLOUD_REGION => 'us-west-2',
ResourceAttributes::CLOUD_RESOURCE_ID => 'arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1',
ResourceAttributes::AWS_ECS_CONTAINER_ARN => 'arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1',
ResourceAttributes::AWS_ECS_CLUSTER_ARN => 'arn:aws:ecs:us-west-2:111122223333:cluster/default',
ResourceAttributes::AWS_ECS_LAUNCHTYPE => 'fargate',
Expand Down Expand Up @@ -418,6 +420,7 @@ public function TestV4ResourceLogDriverFireLens()
ResourceAttributes::CLOUD_ACCOUNT_ID => '111122223333',
ResourceAttributes::CLOUD_AVAILABILITY_ZONE => 'us-west-2a',
ResourceAttributes::CLOUD_REGION => 'us-west-2',
ResourceAttributes::CLOUD_RESOURCE_ID => 'arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1',
ResourceAttributes::AWS_ECS_CONTAINER_ARN => 'arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1',
ResourceAttributes::AWS_ECS_CLUSTER_ARN => 'arn:aws:ecs:us-west-2:111122223333:cluster/default',
ResourceAttributes::AWS_ECS_LAUNCHTYPE => 'fargate',
Expand Down

0 comments on commit 9e25568

Please sign in to comment.