Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
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
- Report `ot-baggage-*` extraction errors from `go.opentelemetry.io/contrib/propagators/ot` to `otel.Handle` instead of silently discarding them, while still attaching the successfully parsed baggage members to the context. (#9395)
- Set `error.type` on the `rpc.client.call.duration` and `rpc.server.call.duration` metrics in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` when the RPC fails with a non-OK status, per the RPC semantic conventions. (#9429)
- Reject OTLP exporter headers with an empty `name` in `go.opentelemetry.io/contrib/otelconf`, `go.opentelemetry.io/contrib/otelconf/x`, and `go.opentelemetry.io/contrib/otelconf/v0.3.0`, instead of forwarding invalid header names to OTLP exporters. (#9102)
- `go.opentelemetry.io/contrib/detectors/aws/lambda` no longer returns an error when run outside of an AWS Lambda environment, matching the no-op behavior of other resource detectors.

<!-- Released section -->
<!-- Don't change this section unless doing release -->
Expand Down
8 changes: 2 additions & 6 deletions detectors/aws/lambda/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package lambda

import (
"context"
"errors"
"os"
"strconv"

Expand All @@ -26,10 +25,7 @@ const (
miB = 1 << 20
)

var (
empty = resource.Empty()
errNotOnLambda = errors.New("process is not on Lambda, cannot detect environment variables from Lambda")
)
var empty = resource.Empty()

// resource detector collects resource information from Lambda environment.
type resourceDetector struct{}
Expand All @@ -47,7 +43,7 @@ func (*resourceDetector) Detect(context.Context) (*resource.Resource, error) {
// Lambda resources come from ENV
lambdaName := os.Getenv(lambdaFunctionNameEnvVar)
if lambdaName == "" {
return empty, errNotOnLambda
return empty, nil
}
awsRegion := os.Getenv(awsRegionEnvVar)
functionVersion := os.Getenv(lambdaFunctionVersionEnvVar)
Expand Down
4 changes: 2 additions & 2 deletions detectors/aws/lambda/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func TestDetectSuccess(t *testing.T) {
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}

// return empty resource when not running on lambda.
// return empty resource and no error when not running on lambda.
func TestReturnsIfNoEnvVars(t *testing.T) {
os.Clearenv()
detector := resourceDetector{}
res, err := detector.Detect(t.Context())

assert.Equal(t, errNotOnLambda, err)
assert.NoError(t, err, "Detector unexpectedly returned error when not running on Lambda")
assert.Empty(t, res.Attributes())
}
Loading