Skip to content

Commit

Permalink
bugfix: remove deprecated resource detectors
Browse files Browse the repository at this point in the history
Fixes #10348

Signed-off-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
Alex Boten committed Jan 4, 2023
1 parent 7677186 commit d2b54d4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 82 deletions.
6 changes: 0 additions & 6 deletions processor/resourcedetectionprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ func NewFactory() processor.Factory {
elasticbeanstalk.TypeStr: elasticbeanstalk.NewDetector,
env.TypeStr: env.NewDetector,
gcp.TypeStr: gcp.NewDetector,
// TODO(#10348): Remove GKE and GCE after the v0.54.0 release.
gcp.DeprecatedGKETypeStr: gcp.NewDetector,
gcp.DeprecatedGCETypeStr: gcp.NewDetector,
system.TypeStr: system.NewDetector,
})

Expand Down Expand Up @@ -208,9 +205,6 @@ func (f *factory) getResourceProvider(
return provider, nil
}

// TODO(#10348): Remove this after the v0.54.0 release.
configuredDetectors = gcp.DeduplicateDetectors(params, configuredDetectors)

detectorTypes := make([]internal.DetectorType, 0, len(configuredDetectors))
for _, key := range configuredDetectors {
detectorTypes = append(detectorTypes, internal.DetectorType(strings.TrimSpace(key)))
Expand Down
32 changes: 0 additions & 32 deletions processor/resourcedetectionprocessor/internal/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ import (
const (
// TypeStr is type of detector.
TypeStr = "gcp"
// 'gke' and 'gce' detectors are replaced with the unified 'gcp' detector
// TODO(#10348): Remove these after the v0.54.0 release.
DeprecatedGKETypeStr = "gke"
DeprecatedGCETypeStr = "gce"
)

// NewDetector returns a detector which can detect resource attributes on:
Expand Down Expand Up @@ -164,31 +160,3 @@ func (r *resourceBuilder) addZoneOrRegion(detect func() (string, gcp.LocationTyp
r.errs = append(r.errs, fmt.Errorf("location must be zone or region. Got %v", locType))
}
}

// DeduplicateDetectors ensures only one of ['gcp','gke','gce'] are present in
// the list of detectors. Currently, users configure both GCE and GKE detectors
// when running on GKE. Resource merge would fail in this case if we don't
// deduplicate, which would break users.
// TODO(#10348): Remove this function after the v0.54.0 release.
func DeduplicateDetectors(set processor.CreateSettings, detectors []string) []string {
var out []string
var found bool
for _, d := range detectors {
switch d {
case DeprecatedGKETypeStr:
set.Logger.Warn("The 'gke' detector is deprecated. Use the 'gcp' detector instead.")
case DeprecatedGCETypeStr:
set.Logger.Warn("The 'gce' detector is deprecated. Use the 'gcp' detector instead.")
case TypeStr:
default:
out = append(out, d)
continue
}
// ensure we only keep the first GCP detector we find.
if !found {
found = true
out = append(out, d)
}
}
return out
}
44 changes: 0 additions & 44 deletions processor/resourcedetectionprocessor/internal/gcp/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/processor/processortest"
conventions "go.opentelemetry.io/collector/semconv/v1.6.1"
"go.uber.org/zap"

Expand Down Expand Up @@ -403,46 +402,3 @@ func (f *fakeGCPDetector) GCEHostName() (string, error) {
}
return f.gceHostName, f.gceHostNameErr
}

func TestDeduplicateDetectors(t *testing.T) {
for _, tc := range []struct {
desc string
in []string
expected []string
}{
{
desc: "empty",
expected: nil,
},
{
desc: "single gcp",
in: []string{"gcp"},
expected: []string{"gcp"},
},
{
desc: "single gce",
in: []string{"gce"},
expected: []string{"gce"},
},
{
desc: "single gke",
in: []string{"gke"},
expected: []string{"gke"},
},
{
desc: "multi",
in: []string{"gcp", "gce", "gke"},
expected: []string{"gcp"},
},
{
desc: "multi with others",
in: []string{"foo", "gcp", "gce", "bar", "gke"},
expected: []string{"foo", "gcp", "bar"},
},
} {
t.Run(tc.desc, func(t *testing.T) {
out := DeduplicateDetectors(processortest.NewNopCreateSettings(), tc.in)
assert.Equal(t, tc.expected, out)
})
}
}

0 comments on commit d2b54d4

Please sign in to comment.