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

Missing jaxrs span in Open Liberty #7870

Closed
fmhwong opened this issue Feb 22, 2023 · 6 comments · Fixed by #7890
Closed

Missing jaxrs span in Open Liberty #7870

fmhwong opened this issue Feb 22, 2023 · 6 comments · Fixed by #7890
Labels
bug Something isn't working

Comments

@fmhwong
Copy link
Contributor

fmhwong commented Feb 22, 2023

Describe the bug
Running a simple JAX-RS application in both WebSphere Application Server traditional and Open Liberty with the latest version of Agent.

I got 3 spans from WebSphere Application Server traditional version 9.0.5.12 on Java 8.

  1. HTTP GET /properties
  2. JAX-RS getProperties()
  3. @WithSpan SystemResources.sleep()

However, I got 2 spans from Open Liberty version 23.0.0.1 on Java 11.

  1. HTTP GET /properties
  2. @WithSpan SystemResources.sleep()

The JAX-RS span is missing from Open Liberty.

Steps to reproduce

import java.util.Random;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import io.opentelemetry.instrumentation.annotations.WithSpan;

@RequestScoped
@Path("/properties")
public class SystemResource {

    private static Random rand = new Random(); 
    
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getProperties() throws InterruptedException {
        sleep(rand.nextInt(500));
        return Response.ok(System.getProperties()).build();
    }

    @WithSpan
    private static void sleep(long ms) throws InterruptedException {
        Thread.sleep(ms);
    }
}

What did you expect to see?
Three spans should be created from Open Liberty.

What did you see instead?
Only two spans were created as described above.

What version are you using?
opentelemetry-javaagent version 1.23.0

Environment
Compiler: OpenJDK 11.0.11
OS: MacOS
Runtime (if different from JDK above): OpenJDK 11.0.17
OS (if different from OS compiled on): Ubuntu 20.04.5 LTS (Focal Fossa) in a container

Additional context

@fmhwong fmhwong added the bug Something isn't working label Feb 22, 2023
@fmhwong
Copy link
Contributor Author

fmhwong commented Feb 22, 2023

@mateuszrzeszutek
Copy link
Member

OpenLiberty 23 uses Javarta EE 9: https://openliberty.io/docs/latest/jakarta-ee9-feature-updates.html
The app server probably does not contain the javax.* classes, it has jakarta.* classes instead.

Have you tried running the example above using the jakarta.ws.* annotations instead?

@mateuszrzeszutek mateuszrzeszutek added the needs author feedback Waiting for additional feedback from the author label Feb 22, 2023
@fmhwong
Copy link
Contributor Author

fmhwong commented Feb 22, 2023

I was testing the above class with jaxrs-2.1 feature in Open Liberty 23.0.0.1. I also tested with the Jakarta EE 9 version of the app with restfulWS-3.0 feature in Open Liberty 23.0.0.1. None of them show the JAX-RS spans.

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Feb 22, 2023
@trask
Copy link
Member

trask commented Feb 22, 2023

@fmhwong if you're able to troubleshoot this and send a PR to fix that would be much appreciated!

@fmhwong
Copy link
Contributor Author

fmhwong commented Feb 23, 2023

Someone has made a PR. I can test it when the fix is available.

laurit added a commit that referenced this issue Feb 24, 2023
Hopefully resolves
#7870
Jax-rs annotation instrumentation is only enabled when jax-rs api is
found in the class loader. This check does a `ClassLoader.getResource`
call for the resource name corresponding to class
`javax.ws.rs.container.AsyncResponse`. As far as I understand this
particular class is used only because it was added in jax-rs 2.0, any
other class added in jax-rs 2.0 could be used instead of it. On
openliberty we fail to find this class because it should be resolved
through bundle dynamic imports but we disable looking into dynamic
imports in
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/internal/internal-eclipse-osgi-3.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/internal/osgi/EclipseOsgiInstrumentation.java
when we do the class presence check. Using a class in `javax.ws.rs.core`
package seems to work better as the import for that package is already
resolved by the time we make the `getResource` call.
@fmhwong
Copy link
Contributor Author

fmhwong commented Mar 1, 2023

The fix is working. Thanks for the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants