Skip to content

Commit

Permalink
add missing cloud.platform in AWS EC2 detector (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmanciop authored Jan 29, 2024
1 parent 0abff5e commit f5f1a71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Aws/src/Ec2/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Detector implements ResourceDetectorInterface
private const AWS_METADATA_TTL_HEADER = 'X-aws-ec2-metadata-token-ttl-seconds';
private const AWS_METADATA_TOKEN_HEADER = 'X-aws-ec2-metadata-token';
private const CLOUD_PROVIDER = 'aws';
private const CLOUD_PLATFORM = 'aws_ec2';

private ClientInterface $client;
private RequestFactoryInterface $requestFactory;
Expand Down Expand Up @@ -112,6 +113,7 @@ public function getResource(): ResourceInfo

$attributes[ResourceAttributes::HOST_NAME] = $hostName;
$attributes[ResourceAttributes::CLOUD_PROVIDER] = self::CLOUD_PROVIDER;
$attributes[ResourceAttributes::CLOUD_PLATFORM] = self::CLOUD_PLATFORM;

return ResourceInfo::create(Attributes::create($attributes), ResourceAttributes::SCHEMA_URL);
} catch (\Throwable $e) {
Expand Down
4 changes: 4 additions & 0 deletions src/Aws/tests/Unit/Ec2/DetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DetectorTest extends TestCase
private const CLOUD_ACCOUNT_ID = 'my-account-id';
private const CLOUD_REGION = 'my-region';
private const CLOUD_PROVIDER = 'aws';
private const CLOUD_PLATFORM = 'aws_ec2';

/**
* @test
Expand Down Expand Up @@ -74,6 +75,7 @@ public function TestValidEc2()
ResourceAttributes::CLOUD_REGION => self::CLOUD_REGION,
ResourceAttributes::HOST_NAME => self::MOCK_HOSTNAME,
ResourceAttributes::CLOUD_PROVIDER => self::CLOUD_PROVIDER,
ResourceAttributes::CLOUD_PLATFORM => self::CLOUD_PLATFORM,
]
),
$detector->getResource()->getAttributes()
Expand Down Expand Up @@ -156,6 +158,7 @@ public function TestInvalidHostName()
ResourceAttributes::CLOUD_ACCOUNT_ID => self::CLOUD_ACCOUNT_ID,
ResourceAttributes::CLOUD_REGION => self::CLOUD_REGION,
ResourceAttributes::CLOUD_PROVIDER => self::CLOUD_PROVIDER,
ResourceAttributes::CLOUD_PLATFORM => self::CLOUD_PLATFORM,
]
),
$detector->getResource()->getAttributes()
Expand Down Expand Up @@ -214,6 +217,7 @@ public function TestInvalidIncompleteIdentities()
ResourceAttributes::HOST_IMAGE_ID => self::HOST_IMAGE_ID,
ResourceAttributes::HOST_NAME => self::MOCK_HOSTNAME,
ResourceAttributes::CLOUD_PROVIDER => self::CLOUD_PROVIDER,
ResourceAttributes::CLOUD_PLATFORM => self::CLOUD_PLATFORM,
]
),
$detector->getResource()->getAttributes()
Expand Down

0 comments on commit f5f1a71

Please sign in to comment.