Skip to content

Commit 07a2bb8

Browse files
committed
Changed featuregate into CLI - instrumentation go
Signed-off-by: Yuri Sa <[email protected]>
1 parent 8d9822a commit 07a2bb8

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

pkg/instrumentation/podmutator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (pm *instPodMutator) Mutate(ctx context.Context, ns corev1.Namespace, pod c
278278
logger.Error(err, "failed to select an OpenTelemetry Instrumentation instance for this pod")
279279
return pod, err
280280
}
281-
if pm.config.enableGoInstrumentation() || inst == nil {
281+
if pm.config.EnableGoAutoInstrumentation() || inst == nil {
282282
insts.Go.Instrumentation = inst
283283
} else {
284284
logger.Error(err, "support for Go auto instrumentation is not enabled")

pkg/instrumentation/upgrade/upgrade.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instru
134134
}
135135
case constants.AnnotationDefaultAutoInstrumentationGo:
136136
if inst.Spec.Go.Image == autoInst {
137-
upgraded.Spec.Go.Image = u.DefaultAutoInstGo
138-
upgraded.Annotations[annotation] = u.DefaultAutoInstGo
137+
upgraded.Spec.Go.Image = u.DefaultAutoInstGo
138+
upgraded.Annotations[annotation] = u.DefaultAutoInstGo
139+
}
139140
}
140-
}
141141
} else {
142142
u.Logger.Error(nil, "autoinstrumentation not enabled for this language", "flag", config.id)
143143
u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", fmt.Sprintf("support for is not enabled for %s", config.id))

pkg/instrumentation/upgrade/upgrade_test.go

-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/go-logr/logr"
2323
"github.com/stretchr/testify/assert"
2424
"github.com/stretchr/testify/require"
25-
colfeaturegate "go.opentelemetry.io/collector/featuregate"
2625
corev1 "k8s.io/api/core/v1"
2726
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2827
"k8s.io/apimachinery/pkg/types"
@@ -32,22 +31,9 @@ import (
3231
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
3332
"github.com/open-telemetry/opentelemetry-operator/internal/config"
3433
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
35-
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
3634
)
3735

3836
func TestUpgrade(t *testing.T) {
39-
originalVal := featuregate.EnableGoAutoInstrumentationSupport.IsEnabled()
40-
require.NoError(t, colfeaturegate.GlobalRegistry().Set(featuregate.EnableGoAutoInstrumentationSupport.ID(), true))
41-
t.Cleanup(func() {
42-
require.NoError(t, colfeaturegate.GlobalRegistry().Set(featuregate.EnableGoAutoInstrumentationSupport.ID(), originalVal))
43-
})
44-
45-
originalVal = featuregate.EnableNginxAutoInstrumentationSupport.IsEnabled()
46-
require.NoError(t, colfeaturegate.GlobalRegistry().Set(featuregate.EnableNginxAutoInstrumentationSupport.ID(), true))
47-
t.Cleanup(func() {
48-
require.NoError(t, colfeaturegate.GlobalRegistry().Set(featuregate.EnableNginxAutoInstrumentationSupport.ID(), originalVal))
49-
})
50-
5137
nsName := strings.ToLower(t.Name())
5238
err := k8sClient.Create(context.Background(), &corev1.Namespace{
5339
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)