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

RUM Javascript injection through the java agent #235

Open
WassimDhib opened this issue Oct 5, 2018 · 5 comments
Open

RUM Javascript injection through the java agent #235

WassimDhib opened this issue Oct 5, 2018 · 5 comments
Labels
instrumentation Instrumentation: framework support, custom plugins, ... new-feature New feature

Comments

@WassimDhib
Copy link

Do you have plans to inject RUM Javascript agent in servlet response ?

To override servlet response methods, you wrap the response in an object that extends ServletResponseWrapper or HttpServletResponseWrapper.

@felixbarny
Copy link
Member

Hi and thanks for the great question. This is something we have already been thinking about, but as of now, there are no concrete plans or a timeline.

@WassimDhib
Copy link
Author

I'm trying to implement this feature on an ongoing project, I would be interested if you have ideas.
there are several problems to be solved, namely

  • to use the wrapper response pattern, you need to extend the javax.servlet.http.HttpServletResponseWrapper class , but by using this class you create a dependency between the agent and a specific implementation of the servlet-api. I ended up using javassist to create wrapper instances programmatically.
  • the javascript injection must be limited to the "text / html" type responses, but this information is not known at the time we add the wrapper, so how do you know the type of response according to the request? actually I use a list of specific extensions but it is not satisfactory.
  • when injecting javascript code, the page size changes so you need to update the ContentLength header. but sometimes this header is not used (when the TransferEncoding is chunked )
  • there is some issues with security, some frameworks (like spring) locks the reponse body
  • the javascript agent code creates a load dependency with the host page. If the javascript is unavailable (or loads slowly), the host page will be affected.

@hmdhk
Copy link

hmdhk commented Oct 10, 2018

From the RUM agent side the following snippet needs to be injected to initialise the agent:

<script src="elastic-apm-js-base/dist/bundles/elastic-apm-js-base.umd.min.js"></script>
<script>
  elasticApm.init({
    serviceName: 'service-name',
    serverUrl: 'http://localhost:8200',
  });
  elasticApm.setInitialPageLoadName('page-name');
</script>

@felixbarny felixbarny added the instrumentation Instrumentation: framework support, custom plugins, ... label Jan 30, 2019
@SylvainJuge SylvainJuge added new-feature New feature and removed [zube]: Backlog labels Feb 1, 2021
@WassimDhib
Copy link
Author

WassimDhib commented Jun 11, 2024

Hi
Any news about this ticket ?
I have seen many projets/applications interested by having rum monitoring
Bu they dont like the idea of modifiying source code of application

@jackshirazi
Copy link
Contributor

Hi, no current plans. There is an otel SIG for this, any support would most likely come from the otel Java agent supporting this and we'll support it through our distribution. But we're unlikely to implement this in our classic agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instrumentation Instrumentation: framework support, custom plugins, ... new-feature New feature
Projects
None yet
Development

No branches or pull requests

6 participants