Skip to content

Commit 0a677d4

Browse files
authored
Bump .NET OTel AutoInstrumentation to 0.3.0-beta.1 (#1056)
Special support for instrumentation list is not needed. By default all instrumentations are enabled.
1 parent 81b51b1 commit 0a677d4

File tree

9 files changed

+8
-77
lines changed

9 files changed

+8
-77
lines changed

README.md

-3
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ The possible values for the annotation can be
226226
* `"my-other-namespace/my-instrumentation"` - name and namespace of `Instrumentation` CR instance in another namespace.
227227
* `"false"` - do not inject
228228

229-
230-
>**Note:** For `DotNet` auto-instrumentation, by default, operator sets the `OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS` environment variable which specifies the list of traces source instrumentations you want to enable. The value that is set by default by the operator is all available instrumentations supported by the `openTelemery-dotnet-instrumentation` release consumed in the image, i.e. `AspNet,HttpClient,SqlClient`. This value can be overriden by configuring the environment variable explicitely.
231-
232229
#### Multi-container pods
233230

234231
If nothing else is specified, instrumentation is performed on the first container available in the pod spec.

apis/v1alpha1/instrumentation_webhook.go

+6-24
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ import (
2727
)
2828

2929
const (
30-
AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image"
31-
AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image"
32-
AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image"
33-
AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image"
34-
envPrefix = "OTEL_"
35-
envSplunkPrefix = "SPLUNK_"
36-
envOtelDotnetAutoTracesEnabledInstrumentations = "OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS"
37-
defaultEnabledTracesInstrumentations = "AspNet,HttpClient,SqlClient"
30+
AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image"
31+
AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image"
32+
AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image"
33+
AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image"
34+
envPrefix = "OTEL_"
35+
envSplunkPrefix = "SPLUNK_"
3836
)
3937

4038
// log is for logging in this package.
@@ -80,13 +78,6 @@ func (r *Instrumentation) Default() {
8078
r.Spec.DotNet.Image = val
8179
}
8280
}
83-
// by default set all the available instrumentations for dotnet unless the env is already set
84-
if !r.isEnvVarSet(envOtelDotnetAutoTracesEnabledInstrumentations) {
85-
r.Spec.DotNet.Env = append(r.Spec.DotNet.Env, corev1.EnvVar{
86-
Name: envOtelDotnetAutoTracesEnabledInstrumentations,
87-
Value: defaultEnabledTracesInstrumentations,
88-
})
89-
}
9081
}
9182

9283
// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1
@@ -155,12 +146,3 @@ func (in *Instrumentation) validateEnv(envs []corev1.EnvVar) error {
155146
}
156147
return nil
157148
}
158-
159-
func (in *Instrumentation) isEnvVarSet(name string) bool {
160-
for _, env := range in.Spec.DotNet.Env {
161-
if env.Name == name {
162-
return true
163-
}
164-
}
165-
return false
166-
}

apis/v1alpha1/instrumentation_webhook_test.go

-32
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"testing"
1919

2020
"github.com/stretchr/testify/assert"
21-
v1 "k8s.io/api/core/v1"
2221
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2322
)
2423

@@ -38,37 +37,6 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) {
3837
assert.Equal(t, "nodejs-img:1", inst.Spec.NodeJS.Image)
3938
assert.Equal(t, "python-img:1", inst.Spec.Python.Image)
4039
assert.Equal(t, "dotnet-img:1", inst.Spec.DotNet.Image)
41-
assert.Equal(t, true, inst.isEnvVarSet(envOtelDotnetAutoTracesEnabledInstrumentations))
42-
}
43-
44-
func TestInstrumentationDefaultingWebhookOtelDotNetTracesEnabledInstruEnvSet(t *testing.T) {
45-
inst := &Instrumentation{
46-
ObjectMeta: metav1.ObjectMeta{
47-
Annotations: map[string]string{
48-
AnnotationDefaultAutoInstrumentationJava: "java-img:1",
49-
AnnotationDefaultAutoInstrumentationNodeJS: "nodejs-img:1",
50-
AnnotationDefaultAutoInstrumentationPython: "python-img:1",
51-
AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1",
52-
},
53-
},
54-
Spec: InstrumentationSpec{
55-
DotNet: DotNet{
56-
Env: []v1.EnvVar{
57-
{
58-
Name: envOtelDotnetAutoTracesEnabledInstrumentations,
59-
Value: "AspNet,HttpClient",
60-
},
61-
},
62-
},
63-
},
64-
}
65-
inst.Default()
66-
for _, env := range inst.Spec.DotNet.Env {
67-
if env.Name == envOtelDotnetAutoTracesEnabledInstrumentations {
68-
assert.Equal(t, "AspNet,HttpClient", env.Value)
69-
break
70-
}
71-
}
7240
}
7341

7442
func TestInstrumentationValidatingWebhook(t *testing.T) {

pkg/instrumentation/dotnet_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestInjectDotNetSDK(t *testing.T) {
3434
}{
3535
{
3636
name: "DOTNET_STARTUP_HOOKS, DOTNET_SHARED_STORE, DOTNET_ADDITIONAL_DEPS not defined",
37-
DotNet: v1alpha1.DotNet{Image: "foo/bar:1", Env: []corev1.EnvVar{{Name: "OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS", Value: "AspNet,HttpClient,SqlClient"}}},
37+
DotNet: v1alpha1.DotNet{Image: "foo/bar:1", Env: []corev1.EnvVar{}},
3838
pod: corev1.Pod{
3939
Spec: corev1.PodSpec{
4040
Containers: []corev1.Container{
@@ -72,10 +72,6 @@ func TestInjectDotNetSDK(t *testing.T) {
7272
},
7373
},
7474
Env: []corev1.EnvVar{
75-
{
76-
Name: "OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS",
77-
Value: "AspNet,HttpClient,SqlClient",
78-
},
7975
{
8076
Name: envDotNetStartupHook,
8177
Value: dotNetStartupHookPath,

tests/e2e/instrumentation-dotnet-multicontainer/01-assert.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ spec:
1313
env:
1414
- name: OTEL_LOG_LEVEL
1515
value: "debug"
16-
- name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS
17-
value: AspNet,HttpClient,SqlClient
1816
- name: DOTNET_STARTUP_HOOKS
1917
value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
2018
- name: DOTNET_ADDITIONAL_DEPS
@@ -48,8 +46,6 @@ spec:
4846
env:
4947
- name: OTEL_LOG_LEVEL
5048
value: "debug"
51-
- name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS
52-
value: AspNet,HttpClient,SqlClient
5349
- name: DOTNET_STARTUP_HOOKS
5450
value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
5551
- name: DOTNET_ADDITIONAL_DEPS

tests/e2e/instrumentation-dotnet-multicontainer/02-assert.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ spec:
1616
env:
1717
- name: OTEL_LOG_LEVEL
1818
value: "debug"
19-
- name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS
20-
value: AspNet,HttpClient,SqlClient
2119
- name: DOTNET_STARTUP_HOOKS
2220
value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
2321
- name: DOTNET_ADDITIONAL_DEPS

tests/e2e/instrumentation-dotnet/00-install-instrumentation.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,3 @@ spec:
2424
sampler:
2525
type: parentbased_traceidratio
2626
argument: "0.25"
27-
dotnet:
28-
env:
29-
- name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS
30-
value: AspNet,HttpClient

tests/e2e/instrumentation-dotnet/01-assert.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ spec:
1010
containers:
1111
- name: myapp
1212
env:
13-
- name: OTEL_DOTNET_AUTO_TRACES_ENABLED_INSTRUMENTATIONS
14-
value: AspNet,HttpClient
1513
- name: DOTNET_STARTUP_HOOKS
1614
value: "/otel-auto-instrumentation/netcoreapp3.1/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
1715
- name: DOTNET_ADDITIONAL_DEPS

versions.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ autoinstrumentation-python=0.32b0
2424

2525
# Represents the current release of DotNet instrumentation.
2626
# Should match autoinstrumentation/dotnet/version.txt
27-
autoinstrumentation-dotnet=0.2.0-beta.1
27+
autoinstrumentation-dotnet=0.3.0-beta.1

0 commit comments

Comments
 (0)