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

To support java17 runtime, substitute wrapper handler for original in exec command line #944

Merged
merged 7 commits into from
Nov 1, 2023

Conversation

johnbley
Copy link
Member

The new java17 runtime appends the configured handler to the command line of the launched java process as an additional app-level argument, and appears to prefer that over the _HANDLER environment variable. This means that our wrapper approach for Java instrumentation stops working since it overrides that variable. I've fixed this by applying some (gnarly looking) bash string substitution on the command line (preserving spaces, argument order, etc.) to swap out this extra argument, and verified that our wrapper gets called again.

@johnbley johnbley requested a review from a team October 11, 2023 13:40
@johnbley
Copy link
Member Author

I notice that the CI didn't run any tests? I thought of switching the runtime of one of the java tests to java17 just to get a little coverage on this. Another option would be to matrix out the tests across all applicable runtimes, though that might get to be too large of a refactoring for one PR. Thoughts?

@tylerbenson
Copy link
Member

(I don't think the java project here has any unit tests... Open to suggestions or contributions for how we might add useful tests without having AWS infrastructure to test against?)

@johnbley
Copy link
Member Author

(I don't think the java project here has any unit tests... Open to suggestions or contributions for how we might add useful tests without having AWS infrastructure to test against?)

We (Splunk) test against real AWS infra; because of stuff like this (PR) I think it'd be best to focus on similar for upstream otel-lamba as well. I realize that's a major task, what with figuring out funding/credentials management/etc. but I think it would be a huge win for this component. Mocking things out just wouldn't uncover these kinds of issues.

Regardless, it appears that's outside the scope for now. Please merge when ready.

exec "$@"
# java17 runtime puts the handler to run as a command line argument and seems to prefer
# this over _HANDLER, so apply a regex to replace the original handler name with our wrapper
exec "${@//$OTEL_INSTRUMENTATION_AWS_LAMBDA_HANDLER/$_HANDLER}"
Copy link
Member

Choose a reason for hiding this comment

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

@johnbley did you confirm this doesn't break anything with Java 11? I assume it doesn't but just want to be sure.
(I think it would still help to include an example string before/after in the PR description on both Java 11 and Java 17 -- unless they're the same.)

Copy link
Member Author

Choose a reason for hiding this comment

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

java17:

sun.java.command=com.amazonaws.services.lambda.runtime.api.client.AWSLambda example.Hello::handleRequest

java11:

sun.java.command=lambdainternal.AWSLambda

And, yes, I verified with our internal tests that this regex works for both 11 and 17.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@johnbley
Copy link
Member Author

Ping! This has been here a while...

@tylerbenson
Copy link
Member

We are currently in limbo between maintainers... The previous maintainers have stepped down but new maintainers haven't been approved yet (#968).

cc @trask

@trask
Copy link
Member

trask commented Oct 31, 2023

sorry for the limbo, I just pinged @open-telemetry/technical-committee to request merging #968 and updating permissions

@tylerbenson tylerbenson merged commit d876343 into open-telemetry:main Nov 1, 2023
8 checks passed
@johnbley johnbley deleted the java17_support branch November 2, 2023 12:02
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.

3 participants