Skip to content
Merged
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 @@ -73,6 +73,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Fixed

- Fix EKS detector erroring outside of Kubernetes. (#7483)
- Fix data race when writing log entries with `context.Context` fields in `go.opentelemetry.io/contrib/bridges/otelzap`. (#7368)
- Fix nil pointer dereference when `ClientTracer` did not have a span in `go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace`. (#7464)
- Record all non-failure metrics on transport round trip errors in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#7146)
Expand Down
4 changes: 4 additions & 0 deletions detectors/aws/eks/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func NewResourceDetector() resource.Detector {
// Detect returns a Resource describing the Amazon EKS environment being run in.
func (detector *resourceDetector) Detect(ctx context.Context) (*resource.Resource, error) {
if detector.err != nil {
if errors.Is(detector.err, rest.ErrNotInCluster) {
return resource.Empty(), nil
}

return nil, detector.err
}

Expand Down
11 changes: 11 additions & 0 deletions detectors/aws/eks/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"k8s.io/client-go/rest"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
Expand Down Expand Up @@ -82,3 +83,13 @@ func TestNotEKS(t *testing.T) {
assert.Equal(t, resource.Empty(), r, "Resource object should be empty")
detectorUtils.AssertExpectations(t)
}

// Tests EKS resource detector not running K8S at all.
func TestNotK8S(t *testing.T) {
detectorUtils := new(MockDetectorUtils)
detector := resourceDetector{utils: detectorUtils, err: rest.ErrNotInCluster}
r, err := detector.Detect(context.Background())
require.NoError(t, err)
assert.Equal(t, resource.Empty(), r, "Resource object should be empty")
detectorUtils.AssertExpectations(t)
}
Loading