@@ -52,77 +52,51 @@ type languageInstrumentations struct {
52
52
Sdk instrumentationWithContainers
53
53
}
54
54
55
- // Check if specific containers are provided for configured instrumentation.
56
55
func (langInsts languageInstrumentations ) areInstrumentedContainersCorrect () (bool , error ) {
57
56
var instrWithoutContainers int
58
57
var instrWithContainers int
59
58
var allContainers []string
60
- var instrumentationWithNoContainers bool
61
59
62
60
// Check for instrumentations with and without containers.
63
61
if langInsts .Java .Instrumentation != nil {
64
62
instrWithContainers += isInstrWithContainers (langInsts .Java )
65
63
instrWithoutContainers += isInstrWithoutContainers (langInsts .Java )
66
64
allContainers = append (allContainers , langInsts .Java .Containers ... )
67
- if len (langInsts .Java .Containers ) == 0 {
68
- instrumentationWithNoContainers = true
69
- }
70
65
}
71
66
if langInsts .NodeJS .Instrumentation != nil {
72
67
instrWithContainers += isInstrWithContainers (langInsts .NodeJS )
73
68
instrWithoutContainers += isInstrWithoutContainers (langInsts .NodeJS )
74
69
allContainers = append (allContainers , langInsts .NodeJS .Containers ... )
75
- if len (langInsts .NodeJS .Containers ) == 0 {
76
- instrumentationWithNoContainers = true
77
- }
78
70
}
79
71
if langInsts .Python .Instrumentation != nil {
80
72
instrWithContainers += isInstrWithContainers (langInsts .Python )
81
73
instrWithoutContainers += isInstrWithoutContainers (langInsts .Python )
82
74
allContainers = append (allContainers , langInsts .Python .Containers ... )
83
- if len (langInsts .Python .Containers ) == 0 {
84
- instrumentationWithNoContainers = true
85
- }
86
75
}
87
76
if langInsts .DotNet .Instrumentation != nil {
88
77
instrWithContainers += isInstrWithContainers (langInsts .DotNet )
89
78
instrWithoutContainers += isInstrWithoutContainers (langInsts .DotNet )
90
79
allContainers = append (allContainers , langInsts .DotNet .Containers ... )
91
- if len (langInsts .DotNet .Containers ) == 0 {
92
- instrumentationWithNoContainers = true
93
- }
94
80
}
95
81
if langInsts .ApacheHttpd .Instrumentation != nil {
96
82
instrWithContainers += isInstrWithContainers (langInsts .ApacheHttpd )
97
83
instrWithoutContainers += isInstrWithoutContainers (langInsts .ApacheHttpd )
98
84
allContainers = append (allContainers , langInsts .ApacheHttpd .Containers ... )
99
- if len (langInsts .ApacheHttpd .Containers ) == 0 {
100
- instrumentationWithNoContainers = true
101
- }
102
85
}
103
86
if langInsts .Nginx .Instrumentation != nil {
104
87
instrWithContainers += isInstrWithContainers (langInsts .Nginx )
105
88
instrWithoutContainers += isInstrWithoutContainers (langInsts .Nginx )
106
89
allContainers = append (allContainers , langInsts .Nginx .Containers ... )
107
- if len (langInsts .Nginx .Containers ) == 0 {
108
- instrumentationWithNoContainers = true
109
- }
110
90
}
111
91
if langInsts .Go .Instrumentation != nil {
112
92
instrWithContainers += isInstrWithContainers (langInsts .Go )
113
93
instrWithoutContainers += isInstrWithoutContainers (langInsts .Go )
114
94
allContainers = append (allContainers , langInsts .Go .Containers ... )
115
- if len (langInsts .Go .Containers ) == 0 {
116
- instrumentationWithNoContainers = true
117
- }
118
95
}
119
96
if langInsts .Sdk .Instrumentation != nil {
120
97
instrWithContainers += isInstrWithContainers (langInsts .Sdk )
121
98
instrWithoutContainers += isInstrWithoutContainers (langInsts .Sdk )
122
99
allContainers = append (allContainers , langInsts .Sdk .Containers ... )
123
- if len (langInsts .Sdk .Containers ) == 0 {
124
- instrumentationWithNoContainers = true
125
- }
126
100
}
127
101
128
102
// Look for duplicated containers.
@@ -131,26 +105,10 @@ func (langInsts languageInstrumentations) areInstrumentedContainersCorrect() (bo
131
105
return false , containerDuplicates
132
106
}
133
107
134
- // Look for mixed multiple instrumentations with and without container names.
135
- if instrWithoutContainers > 0 && instrWithContainers > 0 {
136
- return false , fmt .Errorf ("incorrect instrumentation configuration - please provide container names for all instrumentations" )
137
- }
138
-
139
- // Look for multiple instrumentations without container names.
140
- if instrWithoutContainers > 1 && instrWithContainers == 0 {
141
- return false , fmt .Errorf ("incorrect instrumentation configuration - please provide container names for all instrumentations" )
142
- }
143
-
144
108
if instrWithoutContainers == 0 && instrWithContainers == 0 {
145
109
return false , fmt .Errorf ("instrumentation configuration not provided" )
146
110
}
147
111
148
- enabledInstrumentations := instrWithContainers + instrWithoutContainers
149
-
150
- if enabledInstrumentations > 1 && instrumentationWithNoContainers {
151
- return false , fmt .Errorf ("incorrect instrumentation configuration - please provide container names for all instrumentations" )
152
- }
153
-
154
112
return true , nil
155
113
}
156
114
@@ -397,8 +355,6 @@ func (pm *instPodMutator) Mutate(ctx context.Context, ns corev1.Namespace, pod c
397
355
if err != nil {
398
356
return pod , err
399
357
}
400
-
401
- // We check if provided annotations and instrumentations are valid
402
358
ok , msg := insts .areInstrumentedContainersCorrect ()
403
359
if ! ok {
404
360
logger .V (1 ).Error (msg , "skipping instrumentation injection" )
0 commit comments