diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc4182a08d..c349def8235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ The next release will require at least [Go 1.24]. ### Changed - Change the default span name to be `GET /path` so it complies with the HTTP semantic conventions in `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`. (#7551) +- Change the faas.max_memory unit to be bytes instead of MB to comply with the semantic conventions in `go.opentelemetry.io/contrib/detectors/aws/lambda`. (#7745) - Transform attribute values of `go.opentelemetry.io/otel/attribute.Value` and `go.opentelemetry.io/otel/log.Value` types to appropriate `go.opentelemetry.io/otel/log.Value` type instead of `log.StringValue` in the modules below. (#7660) - `go.opentelemetry.io/contrib/bridges/otellogr` - `go.opentelemetry.io/contrib/bridges/otellogrus` diff --git a/detectors/aws/lambda/detector.go b/detectors/aws/lambda/detector.go index e7c5336e36f..f51286849e4 100644 --- a/detectors/aws/lambda/detector.go +++ b/detectors/aws/lambda/detector.go @@ -23,6 +23,7 @@ const ( lambdaFunctionVersionEnvVar = "AWS_LAMBDA_FUNCTION_VERSION" lambdaLogStreamNameEnvVar = "AWS_LAMBDA_LOG_STREAM_NAME" lambdaMemoryLimitEnvVar = "AWS_LAMBDA_FUNCTION_MEMORY_SIZE" + miB = 1 << 20 ) var ( @@ -65,7 +66,7 @@ func (*resourceDetector) Detect(context.Context) (*resource.Resource, error) { maxMemoryStr := os.Getenv(lambdaMemoryLimitEnvVar) maxMemory, err := strconv.Atoi(maxMemoryStr) if err == nil { - attrs = append(attrs, semconv.FaaSMaxMemory(maxMemory)) + attrs = append(attrs, semconv.FaaSMaxMemory(maxMemory*miB)) } return resource.NewWithAttributes(semconv.SchemaURL, attrs...), nil diff --git a/detectors/aws/lambda/detector_test.go b/detectors/aws/lambda/detector_test.go index d844aa4efe3..3bae8ffc55a 100644 --- a/detectors/aws/lambda/detector_test.go +++ b/detectors/aws/lambda/detector_test.go @@ -28,7 +28,7 @@ func TestDetectSuccess(t *testing.T) { semconv.FaaSName("testFunction"), semconv.FaaSVersion("$LATEST"), semconv.FaaSInstance("2023/01/01/[$LATEST]5d1edb9e525d486696cf01a3503487bc"), - semconv.FaaSMaxMemory(128), + semconv.FaaSMaxMemory(128 * miB), } expectedResource := resource.NewWithAttributes(semconv.SchemaURL, attributes...) detector := resourceDetector{} diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go index 06c48d84338..4278a62ac7d 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go @@ -32,6 +32,8 @@ import ( "go.opentelemetry.io/contrib/propagators/aws/xray" ) +const miB = 1 << 20 + var errorLogger = log.New(log.Writer(), "OTel Lambda Test Error: ", 0) type mockIDGenerator struct { @@ -142,7 +144,7 @@ var ( attribute.String("faas.name", "testFunction"), attribute.String("faas.version", "$LATEST"), attribute.String("faas.instance", "2023/01/01/[$LATEST]5d1edb9e525d486696cf01a3503487bc"), - attribute.Int("faas.max_memory", 128)), + attribute.Int("faas.max_memory", 128*miB)), InstrumentationScope: instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda", Version: otellambda.Version(), @@ -337,7 +339,7 @@ var ( attribute.String("faas.name", "testFunction"), attribute.String("faas.version", "$LATEST"), attribute.String("faas.instance", "2023/01/01/[$LATEST]5d1edb9e525d486696cf01a3503487bc"), - attribute.Int("faas.max_memory", 128)), + attribute.Int("faas.max_memory", 128*miB)), InstrumentationScope: instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda", Version: otellambda.Version(), diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go index dab301b9f22..6e8899001b2 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/xrayconfig/xrayconfig_test.go @@ -23,6 +23,8 @@ import ( "go.opentelemetry.io/contrib/propagators/aws/xray" ) +const miB = 1 << 20 + func TestEventToCarrier(t *testing.T) { t.Setenv("_X_AMZN_TRACE_ID", "traceID") carrier := xrayEventToCarrier([]byte{}) @@ -107,7 +109,7 @@ var ( {Key: "cloud.provider", Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "aws"}}}, {Key: "cloud.region", Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "us-texas-1"}}}, {Key: "faas.instance", Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "2023/01/01/[$LATEST]5d1edb9e525d486696cf01a3503487bc"}}}, - {Key: "faas.max_memory", Value: &v1common.AnyValue{Value: &v1common.AnyValue_IntValue{IntValue: 128}}}, + {Key: "faas.max_memory", Value: &v1common.AnyValue{Value: &v1common.AnyValue_IntValue{IntValue: 128 * miB}}}, {Key: "faas.name", Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "testFunction"}}}, {Key: "faas.version", Value: &v1common.AnyValue{Value: &v1common.AnyValue_StringValue{StringValue: "$LATEST"}}}, },