Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumentations support Java extensions #2761

Merged
merged 8 commits into from
Apr 11, 2024

Conversation

crossoverJie
Copy link
Contributor

Description:

FROM busybox
ADD ex-1.0.0.jar /extensions/ex-1.0.0.jar
RUN chmod -R go+r /extensions/ex-1.0.0.jar
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
  name: my-instrumentation
spec:
  java:
    image: foo/a
    extensions:
      image: foo/b
      dir: /extensions

Operator will copy jars from the ${java.extensions} directory to /otel-auto-instrumentation/extensions.

JVM parameters will also be added to the JAVA_TOOL_OPTIONS environment variable: -Dotel.javaagent.extensions=/otel-auto-instrumentation-java/extensions.

Link to tracking Issue(s):

Testing: https://github.com/crossoverJie/opentelemetry-operator/blob/6727627c897d89ecdc93718f4a8417a0d69a1c48/pkg/instrumentation/javaagent_test.go#L89

Documentation: Later.

@crossoverJie crossoverJie requested a review from a team March 14, 2024 09:25
@crossoverJie crossoverJie changed the title Instrumentations support java extensions Instrumentations support Java extensions Mar 14, 2024

// Extensions defines java specific extensions.
// +optional
Extensions *Extensions `json:"extensions,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if this would be a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right; this makes it easier to integrate some third-party extensions.


type Extensions struct {
// Image is a container image with extensions auto-instrumentation JAR.
Image string `json:"image"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the extension needs to be rebuild for every java agent version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary; the user just needs to package based on the javaagent version he's using.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some open source extensions, maybe it should provide a compatibility list for javaagent.

@pavolloffay
Copy link
Member

Please add a changelog for this

@crossoverJie
Copy link
Contributor Author

Please add a changelog for this

Done, PTAL

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we just need to figure out how to avoid overriding of the extensions

@@ -45,6 +46,11 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.
}
}

javaJVMArgument := javaAgent
if len(javaSpec.Extensions) > 0 {
javaJVMArgument = javaAgent + fmt.Sprintf(" -Dotel.javaagent.extensions=%s/extensions", javaInstrMountPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://opentelemetry.io/docs/languages/java/automatic/configuration/#extensions

If all extensions are copied to the same directory it can cause overrides.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure what the confusion is here.

I think the user should make sure that the jars in the /extensions directory are unique, even if he doesn't use the operator.

@crossoverJie crossoverJie requested a review from pavolloffay April 2, 2024 02:27
@pavolloffay
Copy link
Member

@crossoverJie the basic checks failed. You probably need to regenerate manifests

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just some documentation nits

component: auto-instrumentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Instrumentations support Java extensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Support Java auto-instrumentation extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -133,6 +133,18 @@ type Java struct {
// Resources describes the compute resource requirements.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Extensions defines java specific extensions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crossoverJie all extensions are copied to a single directory, therefore we should document it because one extension can override another one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added related documents.

@swiatekm swiatekm requested a review from pavolloffay April 8, 2024 10:11
@pavolloffay pavolloffay merged commit a3919b9 into open-telemetry:main Apr 11, 2024
31 checks passed
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
* Support extensions

* fix with cr

* fix document

* fix lint
rubenvp8510 pushed a commit to rubenvp8510/opentelemetry-operator that referenced this pull request May 7, 2024
* Support extensions

* fix with cr

* fix document

* fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support opentelemetry Javaagent extensions
3 participants