Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use semconv creation functions #3369

Merged
merged 4 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- The GCE detector in `go.opentelemetry.io/contrib/detectors/gcp` includes the "cloud.region" attribute when appropriate. (#3367)
- The span name of producer spans from `go.opentelemetry.io/contrib/instrumentation/github.com/Shopify/sarama/otelsarama` is corrected to use `publish` instead of `send`. (#3396)
- Attribute types are corrected in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`. (#3396)
- `aws.dynamodb.table_names` is now a string slice value.
- `aws.dynamodb.global_secondary_indexes` is now a string slice value.
- `aws.dynamodb.local_secondary_indexes` is now a string slice value.
- `aws.dynamodb.attribute_definitions` is now a string slice value.
- `aws.dynamodb.global_secondary_index_updates` is now a string slice value.
- `aws.dynamodb.provisioned_read_capacity` is now a `float64` value.
- `aws.dynamodb.provisioned_write_capacity` is now a `float64` value.

## [1.13.0/0.37.0/0.7.0] - 2023-01-30

Expand Down
12 changes: 6 additions & 6 deletions detectors/aws/ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEC2,
semconv.CloudRegionKey.String(doc.Region),
semconv.CloudAvailabilityZoneKey.String(doc.AvailabilityZone),
semconv.CloudAccountIDKey.String(doc.AccountID),
semconv.HostIDKey.String(doc.InstanceID),
semconv.HostImageIDKey.String(doc.ImageID),
semconv.HostTypeKey.String(doc.InstanceType),
semconv.CloudRegion(doc.Region),
semconv.CloudAvailabilityZone(doc.AvailabilityZone),
semconv.CloudAccountID(doc.AccountID),
semconv.HostID(doc.InstanceID),
semconv.HostImageID(doc.ImageID),
semconv.HostType(doc.InstanceType),
}

m := &metadata{client: client}
Expand Down
26 changes: 13 additions & 13 deletions detectors/aws/ec2/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ 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"),
semconv.HostIDKey.String("i-1234567890abcdef0"),
semconv.HostImageIDKey.String("ami-5fb8c835"),
semconv.HostTypeKey.String("t2.micro"),
semconv.CloudRegion("us-west-2"),
semconv.CloudAvailabilityZone("us-west-2b"),
semconv.CloudAccountID("123456789012"),
semconv.HostID("i-1234567890abcdef0"),
semconv.HostImageID("ami-5fb8c835"),
semconv.HostType("t2.micro"),
}

testTable := map[string]struct {
Expand Down Expand Up @@ -139,13 +139,13 @@ func TestAWS_Detect(t *testing.T) {
semconv.SchemaURL,
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEC2,
semconv.CloudRegionKey.String("us-west-2"),
semconv.CloudAvailabilityZoneKey.String("us-west-2b"),
semconv.CloudAccountIDKey.String("123456789012"),
semconv.HostIDKey.String("i-1234567890abcdef0"),
semconv.HostImageIDKey.String("ami-5fb8c835"),
semconv.HostNameKey.String("ip-12-34-56-78.us-west-2.compute.internal"),
semconv.HostTypeKey.String("t2.micro"),
semconv.CloudRegion("us-west-2"),
semconv.CloudAvailabilityZone("us-west-2b"),
semconv.CloudAccountID("123456789012"),
semconv.HostID("i-1234567890abcdef0"),
semconv.HostImageID("ami-5fb8c835"),
semconv.HostName("ip-12-34-56-78.us-west-2.compute.internal"),
semconv.HostType("t2.micro"),
)},
},
}
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ec2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/aws/aws-sdk-go v1.44.194
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c
go.opentelemetry.io/otel/sdk v1.12.0
)

Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/ec2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.opentelemetry.io/otel v1.12.0 h1:IgfC7kqQrRccIKuB7Cl+SRUmsKbEwSGPr0Eu+/ht1SQ=
go.opentelemetry.io/otel v1.12.0/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c h1:akX9DDpsZ8HuPj+qzdyTNbmyCKYG2BHdPn7nJ6Kc6oU=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel/sdk v1.12.0 h1:8npliVYV7qc0t1FKdpU08eMnOjgPFMnriPhn0HH4q3o=
go.opentelemetry.io/otel/sdk v1.12.0/go.mod h1:WYcvtgquYvgODEvxOry5owO2y9MyciW7JqMz6cpXShE=
go.opentelemetry.io/otel/trace v1.12.0 h1:p28in++7Kd0r2d8gSt931O57fdjUyWxkVbESuILAeUc=
Expand Down
22 changes: 11 additions & 11 deletions detectors/aws/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String(hostName),
semconv.ContainerIDKey.String(containerID),
semconv.ContainerName(hostName),
semconv.ContainerID(containerID),
}

if len(metadataURIV4) > 0 {
Expand All @@ -104,7 +104,7 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
}
attributes = append(
attributes,
semconv.AWSECSContainerARNKey.String(containerMetadata.ContainerARN),
semconv.AWSECSContainerARN(containerMetadata.ContainerARN),
)

taskMetadata, err := ecsmetadata.GetTaskV4(ctx, &http.Client{})
Expand All @@ -129,11 +129,11 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc

attributes = append(
attributes,
semconv.AWSECSClusterARNKey.String(clusterArn),
semconv.AWSECSClusterARN(clusterArn),
semconv.AWSECSLaunchtypeKey.String(strings.ToLower(taskMetadata.LaunchType)),
semconv.AWSECSTaskARNKey.String(taskMetadata.TaskARN),
semconv.AWSECSTaskFamilyKey.String(taskMetadata.Family),
semconv.AWSECSTaskRevisionKey.String(taskMetadata.Revision),
semconv.AWSECSTaskARN(taskMetadata.TaskARN),
semconv.AWSECSTaskFamily(taskMetadata.Family),
semconv.AWSECSTaskRevision(taskMetadata.Revision),
)
}

Expand Down Expand Up @@ -166,10 +166,10 @@ func (detector *resourceDetector) getLogsAttributes(metadata *ecsmetadata.Contai
awsAccount := r.FindStringSubmatch(containerArn)[1]

return []attribute.KeyValue{
semconv.AWSLogGroupNamesKey.String(logsOptions.AwsLogsGroup),
semconv.AWSLogGroupARNsKey.String(fmt.Sprintf("arn:aws:logs:%s:%s:log-group:%s:*", logsRegion, awsAccount, logsOptions.AwsLogsGroup)),
semconv.AWSLogStreamNamesKey.String(logsOptions.AwsLogsStream),
semconv.AWSLogStreamARNsKey.String(fmt.Sprintf("arn:aws:logs:%s:%s:log-group:%s:log-stream:%s", logsRegion, awsAccount, logsOptions.AwsLogsGroup, logsOptions.AwsLogsStream)),
semconv.AWSLogGroupNames(logsOptions.AwsLogsGroup),
semconv.AWSLogGroupARNs(fmt.Sprintf("arn:aws:logs:%s:%s:log-group:%s:*", logsRegion, awsAccount, logsOptions.AwsLogsGroup)),
semconv.AWSLogStreamNames(logsOptions.AwsLogsStream),
semconv.AWSLogStreamARNs(fmt.Sprintf("arn:aws:logs:%s:%s:log-group:%s:log-stream:%s", logsRegion, awsAccount, logsOptions.AwsLogsGroup, logsOptions.AwsLogsStream)),
}, nil
}

Expand Down
8 changes: 4 additions & 4 deletions detectors/aws/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func TestDetectV3(t *testing.T) {
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String("container-Name"),
semconv.ContainerIDKey.String("0123456789A"),
semconv.ContainerName("container-Name"),
semconv.ContainerID("0123456789A"),
}
expectedResource := resource.NewWithAttributes(semconv.SchemaURL, attributes...)
detector := &resourceDetector{utils: detectorUtils}
Expand All @@ -78,8 +78,8 @@ func TestDetectCannotReadContainerID(t *testing.T) {
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String("container-Name"),
semconv.ContainerIDKey.String(""),
semconv.ContainerName("container-Name"),
semconv.ContainerID(""),
}
expectedResource := resource.NewWithAttributes(semconv.SchemaURL, attributes...)
detector := &resourceDetector{utils: detectorUtils}
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ecs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/brunoscheufler/aws-ecs-metadata-go v0.0.0-20220812150832-b6b31c6eeeaf
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c
go.opentelemetry.io/otel/sdk v1.12.0
)

Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/ecs/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.opentelemetry.io/otel v1.12.0 h1:IgfC7kqQrRccIKuB7Cl+SRUmsKbEwSGPr0Eu+/ht1SQ=
go.opentelemetry.io/otel v1.12.0/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c h1:akX9DDpsZ8HuPj+qzdyTNbmyCKYG2BHdPn7nJ6Kc6oU=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel/sdk v1.12.0 h1:8npliVYV7qc0t1FKdpU08eMnOjgPFMnriPhn0HH4q3o=
go.opentelemetry.io/otel/sdk v1.12.0/go.mod h1:WYcvtgquYvgODEvxOry5owO2y9MyciW7JqMz6cpXShE=
go.opentelemetry.io/otel/trace v1.12.0 h1:p28in++7Kd0r2d8gSt931O57fdjUyWxkVbESuILAeUc=
Expand Down
44 changes: 22 additions & 22 deletions detectors/aws/ecs/test/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ func TestDetectV4LaunchTypeEc2(t *testing.T) {
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String(hostname),
semconv.ContainerName(hostname),
// We are not running the test in an actual container,
// the container id is tested with mocks of the cgroup
// file in the unit tests
semconv.ContainerIDKey.String(""),
semconv.AWSECSContainerARNKey.String("arn:aws:ecs:us-west-2:111122223333:container/0206b271-b33f-47ab-86c6-a0ba208a70a9"),
semconv.AWSECSClusterARNKey.String("arn:aws:ecs:us-west-2:111122223333:cluster/default"),
semconv.ContainerID(""),
semconv.AWSECSContainerARN("arn:aws:ecs:us-west-2:111122223333:container/0206b271-b33f-47ab-86c6-a0ba208a70a9"),
semconv.AWSECSClusterARN("arn:aws:ecs:us-west-2:111122223333:cluster/default"),
semconv.AWSECSLaunchtypeKey.String("ec2"),
semconv.AWSECSTaskARNKey.String("arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c"),
semconv.AWSECSTaskFamilyKey.String("curltest"),
semconv.AWSECSTaskRevisionKey.String("26"),
semconv.AWSLogGroupNamesKey.String("/ecs/metadata"),
semconv.AWSLogGroupARNsKey.String("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata:*"),
semconv.AWSLogStreamNamesKey.String("ecs/curl/8f03e41243824aea923aca126495f665"),
semconv.AWSLogStreamARNsKey.String("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata:log-stream:ecs/curl/8f03e41243824aea923aca126495f665"),
semconv.AWSECSTaskARN("arn:aws:ecs:us-west-2:111122223333:task/default/158d1c8083dd49d6b527399fd6414f5c"),
semconv.AWSECSTaskFamily("curltest"),
semconv.AWSECSTaskRevision("26"),
semconv.AWSLogGroupNames("/ecs/metadata"),
semconv.AWSLogGroupARNs("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata:*"),
semconv.AWSLogStreamNames("ecs/curl/8f03e41243824aea923aca126495f665"),
semconv.AWSLogStreamARNs("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/metadata:log-stream:ecs/curl/8f03e41243824aea923aca126495f665"),
}
expectedResource := resource.NewWithAttributes(semconv.SchemaURL, attributes...)
detector := ecs.NewResourceDetector()
Expand Down Expand Up @@ -124,21 +124,21 @@ func TestDetectV4LaunchTypeFargate(t *testing.T) {
attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSECS,
semconv.ContainerNameKey.String(hostname),
semconv.ContainerName(hostname),
// We are not running the test in an actual container,
// the container id is tested with mocks of the cgroup
// file in the unit tests
semconv.ContainerIDKey.String(""),
semconv.AWSECSContainerARNKey.String("arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1"),
semconv.AWSECSClusterARNKey.String("arn:aws:ecs:us-west-2:111122223333:cluster/default"),
semconv.ContainerID(""),
semconv.AWSECSContainerARN("arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1"),
semconv.AWSECSClusterARN("arn:aws:ecs:us-west-2:111122223333:cluster/default"),
semconv.AWSECSLaunchtypeKey.String("fargate"),
semconv.AWSECSTaskARNKey.String("arn:aws:ecs:us-west-2:111122223333:task/default/e9028f8d5d8e4f258373e7b93ce9a3c3"),
semconv.AWSECSTaskFamilyKey.String("curltest"),
semconv.AWSECSTaskRevisionKey.String("3"),
semconv.AWSLogGroupNamesKey.String("/ecs/containerlogs"),
semconv.AWSLogGroupARNsKey.String("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/containerlogs:*"),
semconv.AWSLogStreamNamesKey.String("ecs/curl/cd189a933e5849daa93386466019ab50"),
semconv.AWSLogStreamARNsKey.String("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/containerlogs:log-stream:ecs/curl/cd189a933e5849daa93386466019ab50"),
semconv.AWSECSTaskARN("arn:aws:ecs:us-west-2:111122223333:task/default/e9028f8d5d8e4f258373e7b93ce9a3c3"),
semconv.AWSECSTaskFamily("curltest"),
semconv.AWSECSTaskRevision("3"),
semconv.AWSLogGroupNames("/ecs/containerlogs"),
semconv.AWSLogGroupARNs("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/containerlogs:*"),
semconv.AWSLogStreamNames("ecs/curl/cd189a933e5849daa93386466019ab50"),
semconv.AWSLogStreamARNs("arn:aws:logs:us-west-2:111122223333:log-group:/ecs/containerlogs:log-stream:ecs/curl/cd189a933e5849daa93386466019ab50"),
}
expectedResource := resource.NewWithAttributes(semconv.SchemaURL, attributes...)
detector := ecs.NewResourceDetector()
Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/eks/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
return nil, err
}
if clusterName != "" {
attributes = append(attributes, semconv.K8SClusterNameKey.String(clusterName))
attributes = append(attributes, semconv.K8SClusterName(clusterName))
}

// Get containerID and append to attributes
Expand All @@ -108,7 +108,7 @@ func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resourc
return nil, err
}
if containerID != "" {
attributes = append(attributes, semconv.ContainerIDKey.String(containerID))
attributes = append(attributes, semconv.ContainerID(containerID))
}

// Return new resource object with clusterName and containerID as attributes
Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/eks/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func TestEks(t *testing.T) {
eksResourceLabels := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudPlatformAWSEKS,
semconv.K8SClusterNameKey.String("my-cluster"),
semconv.ContainerIDKey.String("0123456789A"),
semconv.K8SClusterName("my-cluster"),
semconv.ContainerID("0123456789A"),
}
expectedResource := resource.NewWithAttributes(semconv.SchemaURL, eksResourceLabels...)

Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/eks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c
go.opentelemetry.io/otel/sdk v1.12.0
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/eks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v1.12.0 h1:IgfC7kqQrRccIKuB7Cl+SRUmsKbEwSGPr0Eu+/ht1SQ=
go.opentelemetry.io/otel v1.12.0/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c h1:akX9DDpsZ8HuPj+qzdyTNbmyCKYG2BHdPn7nJ6Kc6oU=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel/sdk v1.12.0 h1:8npliVYV7qc0t1FKdpU08eMnOjgPFMnriPhn0HH4q3o=
go.opentelemetry.io/otel/sdk v1.12.0/go.mod h1:WYcvtgquYvgODEvxOry5owO2y9MyciW7JqMz6cpXShE=
go.opentelemetry.io/otel/trace v1.12.0 h1:p28in++7Kd0r2d8gSt931O57fdjUyWxkVbESuILAeUc=
Expand Down
10 changes: 5 additions & 5 deletions detectors/aws/lambda/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ func (detector *resourceDetector) Detect(context.Context) (*resource.Resource, e

attrs := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudRegionKey.String(awsRegion),
semconv.FaaSInstanceKey.String(instance),
semconv.FaaSNameKey.String(lambdaName),
semconv.FaaSVersionKey.String(functionVersion),
semconv.CloudRegion(awsRegion),
semconv.FaaSInstance(instance),
semconv.FaaSName(lambdaName),
semconv.FaaSVersion(functionVersion),
}

maxMemoryStr := os.Getenv(lambdaMemoryLimitEnvVar)
maxMemory, err := strconv.Atoi(maxMemoryStr)
if err == nil {
attrs = append(attrs, semconv.FaaSMaxMemoryKey.Int(maxMemory))
attrs = append(attrs, semconv.FaaSMaxMemory(maxMemory))
}

return resource.NewWithAttributes(semconv.SchemaURL, attrs...), nil
Expand Down
10 changes: 5 additions & 5 deletions detectors/aws/lambda/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func TestDetectSuccess(t *testing.T) {

attributes := []attribute.KeyValue{
semconv.CloudProviderAWS,
semconv.CloudRegionKey.String("us-texas-1"),
semconv.FaaSNameKey.String("testFunction"),
semconv.FaaSVersionKey.String("$LATEST"),
semconv.FaaSInstanceKey.String("2023/01/01/[$LATEST]5d1edb9e525d486696cf01a3503487bc"),
semconv.FaaSMaxMemoryKey.Int(128),
semconv.CloudRegion("us-texas-1"),
semconv.FaaSName("testFunction"),
semconv.FaaSVersion("$LATEST"),
semconv.FaaSInstance("2023/01/01/[$LATEST]5d1edb9e525d486696cf01a3503487bc"),
semconv.FaaSMaxMemory(128),
}
expectedResource := resource.NewWithAttributes(semconv.SchemaURL, attributes...)
detector := resourceDetector{}
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/lambda/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c
go.opentelemetry.io/otel/sdk v1.12.0
)

Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/lambda/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.opentelemetry.io/otel v1.12.0 h1:IgfC7kqQrRccIKuB7Cl+SRUmsKbEwSGPr0Eu+/ht1SQ=
go.opentelemetry.io/otel v1.12.0/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c h1:akX9DDpsZ8HuPj+qzdyTNbmyCKYG2BHdPn7nJ6Kc6oU=
go.opentelemetry.io/otel v1.12.1-0.20230206174141-0446207a380c/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0=
go.opentelemetry.io/otel/sdk v1.12.0 h1:8npliVYV7qc0t1FKdpU08eMnOjgPFMnriPhn0HH4q3o=
go.opentelemetry.io/otel/sdk v1.12.0/go.mod h1:WYcvtgquYvgODEvxOry5owO2y9MyciW7JqMz6cpXShE=
go.opentelemetry.io/otel/trace v1.12.0 h1:p28in++7Kd0r2d8gSt931O57fdjUyWxkVbESuILAeUc=
Expand Down
6 changes: 3 additions & 3 deletions detectors/gcp/cloud-function.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func (f *cloudFunction) Detect(ctx context.Context) (*resource.Resource, error)
attributes := []attribute.KeyValue{
semconv.CloudProviderGCP,
semconv.CloudPlatformGCPCloudFunctions,
semconv.FaaSNameKey.String(functionName),
semconv.CloudAccountIDKey.String(projectID),
semconv.CloudRegionKey.String(region),
semconv.FaaSName(functionName),
semconv.CloudAccountID(projectID),
semconv.CloudRegion(region),
}
return resource.NewWithAttributes(semconv.SchemaURL, attributes...), nil
}
Expand Down
6 changes: 3 additions & 3 deletions detectors/gcp/cloud-function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func TestCloudFunctionDetect(t *testing.T) {
res: resource.NewSchemaless([]attribute.KeyValue{
semconv.CloudProviderGCP,
semconv.CloudPlatformGCPCloudFunctions,
semconv.FaaSNameKey.String(functionName),
semconv.CloudAccountIDKey.String(projectIDValue),
semconv.CloudRegionKey.String(regionValue),
semconv.FaaSName(functionName),
semconv.CloudAccountID(projectIDValue),
semconv.CloudRegion(regionValue),
}...),
err: nil,
},
Expand Down
Loading