Skip to content

Commit 3214fef

Browse files
committed
fix with cr
1 parent 924d6e3 commit 3214fef

8 files changed

+73
-42
lines changed

.chloggen/support-extensions.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: auto-instrumentation
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Instrumentations support Java extensions
9+
10+
# One or more tracking issues related to the change
11+
issues: [1785]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

apis/v1alpha1/instrumentation_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ type Java struct {
136136

137137
// Extensions defines java specific extensions.
138138
// +optional
139-
Extensions *Extensions `json:"extensions,omitempty"`
139+
Extensions []Extensions `json:"extensions,omitempty"`
140140
}
141141

142142
type Extensions struct {

apis/v1alpha1/zz_generated.deepcopy.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/opentelemetry.io_instrumentations.yaml

+15-13
Original file line numberDiff line numberDiff line change
@@ -921,19 +921,21 @@ spec:
921921
type: array
922922
extensions:
923923
description: Extensions defines java specific extensions.
924-
properties:
925-
dir:
926-
description: Dir is a directory with extensions auto-instrumentation
927-
JAR.
928-
type: string
929-
image:
930-
description: Image is a container image with extensions auto-instrumentation
931-
JAR.
932-
type: string
933-
required:
934-
- dir
935-
- image
936-
type: object
924+
items:
925+
properties:
926+
dir:
927+
description: Dir is a directory with extensions auto-instrumentation
928+
JAR.
929+
type: string
930+
image:
931+
description: Image is a container image with extensions
932+
auto-instrumentation JAR.
933+
type: string
934+
required:
935+
- dir
936+
- image
937+
type: object
938+
type: array
937939
image:
938940
description: Image is a container image with javaagent auto-instrumentation
939941
JAR.

config/crd/bases/opentelemetry.io_instrumentations.yaml

+15-13
Original file line numberDiff line numberDiff line change
@@ -919,19 +919,21 @@ spec:
919919
type: array
920920
extensions:
921921
description: Extensions defines java specific extensions.
922-
properties:
923-
dir:
924-
description: Dir is a directory with extensions auto-instrumentation
925-
JAR.
926-
type: string
927-
image:
928-
description: Image is a container image with extensions auto-instrumentation
929-
JAR.
930-
type: string
931-
required:
932-
- dir
933-
- image
934-
type: object
922+
items:
923+
properties:
924+
dir:
925+
description: Dir is a directory with extensions auto-instrumentation
926+
JAR.
927+
type: string
928+
image:
929+
description: Image is a container image with extensions
930+
auto-instrumentation JAR.
931+
type: string
932+
required:
933+
- dir
934+
- image
935+
type: object
936+
type: array
935937
image:
936938
description: Image is a container image with javaagent auto-instrumentation
937939
JAR.

docs/api.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1907,8 +1907,8 @@ Java defines configuration for java auto-instrumentation.
19071907
</td>
19081908
<td>false</td>
19091909
</tr><tr>
1910-
<td><b><a href="#instrumentationspecjavaextensions">extensions</a></b></td>
1911-
<td>object</td>
1910+
<td><b><a href="#instrumentationspecjavaextensionsindex">extensions</a></b></td>
1911+
<td>[]object</td>
19121912
<td>
19131913
Extensions defines java specific extensions.<br/>
19141914
</td>
@@ -2195,12 +2195,12 @@ TODO: Add other useful fields. apiVersion, kind, uid?<br/>
21952195
</table>
21962196

21972197

2198-
### Instrumentation.spec.java.extensions
2198+
### Instrumentation.spec.java.extensions[index]
21992199
<sup><sup>[↩ Parent](#instrumentationspecjava)</sup></sup>
22002200

22012201

22022202

2203-
Extensions defines java specific extensions.
2203+
22042204

22052205
<table>
22062206
<thead>

pkg/instrumentation/javaagent.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package instrumentation
1616

1717
import (
1818
"fmt"
19-
2019
corev1 "k8s.io/api/core/v1"
2120

2221
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
@@ -48,7 +47,7 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.
4847
}
4948

5049
javaJVMArgument := javaAgent
51-
if javaSpec.Extensions != nil {
50+
if len(javaSpec.Extensions) > 0 {
5251
javaJVMArgument = javaAgent + fmt.Sprintf(" -Dotel.javaagent.extensions=%s/extensions", javaInstrMountPath)
5352
}
5453

@@ -88,11 +87,11 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.
8887
}},
8988
})
9089

91-
if javaSpec.Extensions != nil {
90+
for i, extension := range javaSpec.Extensions {
9291
pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{
93-
Name: initContainerName + "-extensions",
94-
Image: javaSpec.Extensions.Image,
95-
Command: []string{"cp", "-r", javaSpec.Extensions.Dir, javaInstrMountPath + "/extensions"},
92+
Name: initContainerName + fmt.Sprintf("-extension-%d", i),
93+
Image: extension.Image,
94+
Command: []string{"cp", "-r", extension.Dir + "/.", javaInstrMountPath + "/extensions"},
9695
Resources: javaSpec.Resources,
9796
VolumeMounts: []corev1.VolumeMount{{
9897
Name: javaVolumeName,

pkg/instrumentation/javaagent_test.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ func TestInjectJavaagent(t *testing.T) {
8787
},
8888
{
8989
name: "add extensions to JAVA_TOOL_OPTIONS",
90-
Java: v1alpha1.Java{Image: "foo/bar:1", Extensions: &v1alpha1.Extensions{Image: "ex/ex:1", Dir: "/ex"}},
90+
Java: v1alpha1.Java{Image: "foo/bar:1", Extensions: []v1alpha1.Extensions{
91+
{Image: "ex/ex:0", Dir: "/ex0"},
92+
{Image: "ex/ex:1", Dir: "/ex1"},
93+
}},
9194
pod: corev1.Pod{
9295
Spec: corev1.PodSpec{
9396
Containers: []corev1.Container{
@@ -118,9 +121,18 @@ func TestInjectJavaagent(t *testing.T) {
118121
}},
119122
},
120123
{
121-
Name: "opentelemetry-auto-instrumentation-extensions",
124+
Name: "opentelemetry-auto-instrumentation-extension-0",
125+
Image: "ex/ex:0",
126+
Command: []string{"cp", "-r", "/ex0/.", "/otel-auto-instrumentation-java/extensions"},
127+
VolumeMounts: []corev1.VolumeMount{{
128+
Name: "opentelemetry-auto-instrumentation-java",
129+
MountPath: "/otel-auto-instrumentation-java",
130+
}},
131+
},
132+
{
133+
Name: "opentelemetry-auto-instrumentation-extension-1",
122134
Image: "ex/ex:1",
123-
Command: []string{"cp", "-r", "/ex", "/otel-auto-instrumentation-java/extensions"},
135+
Command: []string{"cp", "-r", "/ex1/.", "/otel-auto-instrumentation-java/extensions"},
124136
VolumeMounts: []corev1.VolumeMount{{
125137
Name: "opentelemetry-auto-instrumentation-java",
126138
MountPath: "/otel-auto-instrumentation-java",

0 commit comments

Comments
 (0)