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 transaction name randomly on Jersey API endpoints #581

Closed
alvarotorrico opened this issue Apr 14, 2019 · 7 comments · Fixed by #597
Closed

Missing transaction name randomly on Jersey API endpoints #581

alvarotorrico opened this issue Apr 14, 2019 · 7 comments · Fixed by #597
Assignees
Labels
bug Bugs

Comments

@alvarotorrico
Copy link

alvarotorrico commented Apr 14, 2019

I'm trying to integrate Elastic APM in our Spring Boot with Jersey API which basically is configured as below:
JerseyConfigurarion.java

@Component
@ApplicationPath("/api")
public class JerseyConfiguration extends ResourceConfig {
    public JerseyConfiguration() {
        packages(true, 
            "my.package1",
            "my.package2"
            )
    } 
}

ProfileResource.java

@Component
@Singleton
@Path("/private/profile")
public class PrivateProfilesResource {
    
    @GET
    @Consumes(…)
    @Produces(…)
    public Profile getProfile(@PathParam(PROFILE_ID) final String profileId) {
        …
    }
}

When I run the app with the java agent, monitoring starts to work but only some times the name displayed for transactions is the correct one, i.e. "ProfileResource#getProfile" most of the times is displayed as "ServletContainer#doGet". Exactly the same is happening for PUT, POST, ... so there is no way to know the real statistic of endpoints because most of the calls to all the different GET are bundled in ServletContainer#doGet

image

I tried with version 1.4.0 and 1.5.0 with same result. I also tried several configurations by setting "application_packages", "trace_methods", "enable_jaxrs_annotation_inheritance", "allow_path_on_hierarchy", "disable_instrumentations=incubating,servlet-api" but none of them solved my problem.

I'm wondering if this is a kind of bug in the agent as it is really weird that the correct name is captured only from time to time.
I would really appreciate your help with this.

@eyalkoren
Copy link
Contributor

This is indeed strange and not the expected behaviour.
In order to analyze the problem, let's start by losing all of the above configurations except enable_jaxrs_annotation_inheritance. Please set the log level configuration to TRACE, run your application, make a few calls to the tested endpoints and upload the full log.

In addition, any information about your Resource typing structures can be useful, for example: inheritance- are some Resources extending a base resource? Or some resources implement a common interface annotated with JAX-RS stuff? etc.

@alvarotorrico
Copy link
Author

alvarotorrico commented Apr 15, 2019

Thanks for your quick response.
About inheritance, actually I refactored the whole API to remove sub-resources thinking on that was the cause of this issue. So, right now there is not inheritance in the API and all the resources have a class level path (plus the "/api" placed in the main configuration class of Jersey).
I did what you told me and I have the trace log, I have to review it for the sensitive information that may contain and I will send you as soon as possible.

EDIT: This is the log. This time I called 3 times to the same endpoint, the two first calls were displayed as ServletContainer.doGet, the third one was correctly named.

elastic-apm_TRACE_TESTING_OB.log

@felixbarny
Copy link
Member

Judging from your logs it seems like it's only setting the correct name in case the transaction is sampled. Could you try out to set transaction_sample_rate to 1 and then to 0 and see if it deterministically sets the correct name when the value is 1 and the wrong value when set to 0?

@felixbarny
Copy link
Member

Oh, I have found the bug. It does have to do with sampling.

@alvarotorrico
Copy link
Author

Thank you for investigate this!!
Can you tell me when you are planning to release the fix if you have any estimation?

@eyalkoren
Copy link
Contributor

You can register to get release notifications on our repo.
Until then, you can test this bugfix build.

@alvarotorrico
Copy link
Author

Thank you @eyalkoren

@SylvainJuge SylvainJuge added bug Bugs and removed type: bug labels Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants