Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### 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)
Comment thread
dmathieu marked this conversation as resolved.
Outdated

### Deprecated

Expand Down
3 changes: 2 additions & 1 deletion detectors/aws/lambda/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/lambda/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down