Skip to content

Commit

Permalink
Add cloud.provider and cloud.platform to AWS detectors (#1043)
Browse files Browse the repository at this point in the history
* Add cloud.provider and cloud.platform to AWS detectors

* Update PR number

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
  • Loading branch information
abihf and Aneurysm9 authored Sep 3, 2021
1 parent 265ebea commit 2c59f62
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Split `go.opentelemetry.io/contrib/propagators` module into `b3`, `jaeger`, `ot` modules. (#985)
- `otelmongodb` span attributes, name and span status now conform to specification. (#769)
- Migrated EC2 resource detector support from root module `go.opentelemetry.io/contrib/detectors/aws` to a separate EC2 resource detector module `go.opentelemetry.io/contrib/detectors/aws/ec2` (#1017)
- Add `cloud.provider` and `cloud.platform` to AWS detectors. (#1043)
- `otelhttptrace.NewClientTrace` now redacts known sensitive headers by default. (#879)

### Fixed
Expand Down
1 change: 1 addition & 0 deletions detectors/aws/ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (aws *AWS) Detect(ctx context.Context) (*resource.Resource, error) {

attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEC2,
semconv.CloudRegionKey.String(doc.Region),
semconv.CloudAvailabilityZoneKey.String(doc.AvailabilityZone),
semconv.CloudAccountIDKey.String(doc.AccountID),
Expand Down
2 changes: 2 additions & 0 deletions detectors/aws/ec2/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func TestAWS_Detect(t *testing.T) {

usWestIDLabels := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEC2,
semconv.CloudRegionKey.String("us-west-2"),
semconv.CloudAvailabilityZoneKey.String("us-west-2b"),
semconv.CloudAccountIDKey.String("123456789012"),
Expand Down Expand Up @@ -137,6 +138,7 @@ func TestAWS_Detect(t *testing.T) {
Want: want{Resource: resource.NewWithAttributes(
semconv.SchemaURL,
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEC2,
semconv.CloudRegionKey.String("us-west-2"),
semconv.CloudAvailabilityZoneKey.String("us-west-2b"),
semconv.CloudAccountIDKey.String("123456789012"),
Expand Down
2 changes: 2 additions & 0 deletions detectors/aws/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
return empty, err
}
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String(hostName),
semconv.ContainerIDKey.String(containerID),
}
Expand Down
2 changes: 2 additions & 0 deletions detectors/aws/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func TestDetect(t *testing.T) {
detectorUtils.On("getContainerID").Return("0123456789A", nil)

attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String("container-Name"),
semconv.ContainerIDKey.String("0123456789A"),
}
Expand Down
5 changes: 4 additions & 1 deletion detectors/aws/eks/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
}

// Create variable to hold resource attributes
attributes := []attribute.KeyValue{}
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEKS,
}

// Get clusterName and append to attributes
clusterName, err := getClusterName(ctx, detector.utils)
Expand Down
2 changes: 2 additions & 0 deletions detectors/aws/eks/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func TestEks(t *testing.T) {

// Expected resource object
eksResourceLabels := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEKS,
semconv.K8SClusterNameKey.String("my-cluster"),
semconv.ContainerIDKey.String("0123456789A"),
}
Expand Down

0 comments on commit 2c59f62

Please sign in to comment.