Skip to content

Conversation

@tobiasstadler
Copy link
Contributor

What does this PR do?

I added support for instrumenting the Java LDAP client

Checklist

  • This is an enhancement of existing features, or a new feature in existing plugins
    • I have updated CHANGELOG.asciidoc
    • I have added tests that prove my fix is effective or that my feature works
    • Added an API method or config option? Document in which version this will be introduced
    • I have made corresponding changes to the documentation

@github-actions github-actions bot added agent-java community Issues and PRs created by the community triage labels Dec 18, 2021
@github-actions
Copy link

👋 @tobiasstadler Thanks a lot for your contribution!

It may take some time before we review a PR, so even if you don’t see activity for some time, it does not mean that we have forgotten about it.

Every once in a while we go through a process of prioritization, after which we are focussing on the tasks that were planned for the upcoming milestone. The prioritization status is typically reflected through the PR labels. It could be pending triage, a candidate for a future milestone, or have a target milestone set to it.

@ghost
Copy link

ghost commented Dec 18, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Reason: null

  • Start Time: 2022-01-28T08:47:23.776+0000

  • Duration: 49 min 27 sec

  • Commit: 2490158

Test stats 🧪

Test Results
Failed 0
Passed 2461
Skipped 16
Total 2477

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark tests.

  • run jdk compatibility tests : Run the JDK Compatibility tests.

  • run integration tests : Run the Agent Integration tests.

  • run end-to-end tests : Run the APM-ITs.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@SylvainJuge SylvainJuge added the new-feature New feature label Jan 25, 2022
@tobiasstadler
Copy link
Contributor Author

@felixbarny Could you please review this PR also?

@felixbarny
Copy link
Member

run elasticsearch-ci/docs

@felixbarny felixbarny enabled auto-merge (squash) January 28, 2022 08:47
@felixbarny felixbarny merged commit 84e8f8b into elastic:main Jan 28, 2022
@tobiasstadler
Copy link
Contributor Author

Thank you!

@tobiasstadler tobiasstadler deleted the java-ldap branch January 28, 2022 10:17
Comment on lines +26 to +27
import com.sun.jndi.ldap.Connection;
import com.sun.jndi.ldap.LdapResult;
Copy link
Member

Choose a reason for hiding this comment

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

Seems like IntelliJ has issues with the imports from the java.naming/com.sun.jndi.ldap module.

Screen Shot 2022-01-28 at 13 52 13

Applying the suggestion only works until the maven project is reloaded.

I've tried adding

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgs>
                        <arg>--add-exports</arg>
                        <arg>java.naming/com.sun.jndi.ldap=ALL-UNNAMED</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>

But that yields this error: java: exporting a package from system module java.naming is not allowed with --release

@tobiasstadler Did you manage to get this work in an IDE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you please try adding <maven.compiler.source>1.7</maven.compiler.source> to the properties of the plugin pom?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem probably is that the IntelliJ profile in the parent pom sets maven.compiler.target and maven.compiler.target to 11.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, right. This works. However, only with a Java 11 compiler. With Java 17 there are still a few issues. Under Preferences > Build, Execution, Deployment > Compiler > Java Compiler, I had to uncheck the Use '--release' option for cross-compilation option. But even after doing that, the tests fail with an IllegalAccessError:

java.lang.IllegalAccessError: class co.elastic.apm.agent.java_ldap.LdapClientAdvice (in unnamed module @0x25be445f) cannot access class com.sun.jndi.ldap.Connection (in module java.naming) because module java.naming does not export com.sun.jndi.ldap to unnamed module @0x25be445f
	at co.elastic.apm.agent.java_ldap.LdapClientAdvice.onEnter(LdapClientAdvice.java:55)
	at java.naming/com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:153)
    ...

This will fail the Java 17 compatibility tests and it's probably also an issue in production with Java 17.

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 just tested it with Java17. It compiles fine but the tests are failing with the error you mentioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

felixbarny added a commit to felixbarny/apm-agent-java that referenced this pull request Jan 28, 2022
@felixbarny felixbarny mentioned this pull request Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-java community Issues and PRs created by the community new-feature New feature triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants