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

JavaScript Snippet Injection #7650

Merged
merged 42 commits into from
Apr 26, 2023
Merged

JavaScript Snippet Injection #7650

merged 42 commits into from
Apr 26, 2023

Conversation

siyuniu-ms
Copy link
Contributor

@siyuniu-ms siyuniu-ms commented Jan 25, 2023

Open Questions

1. Character encoding

  • what if one of the <head> tag characters is split across two bytes in some character encoding?
  • what if some character encoding translates a character to <h and we think it looks like the beginning of a head tag?

2. What if ServletOutputStream delegates to another ServletOutputStream?

Currently the instrumentation may inject the snippet twice.

Thoughts: Could use ThreadLocal to suppress duplicate injection?

Future Work

1. Support Servlet 5

2. Content Type set after calling getOutputStream or getWriter

Currently, injection is not performed in this case.

Cases: static html and JSP Possible solution: as soon as the content type is being set, create injection state and connect the state to servlet out put stream and print writer

3. Support head attributes, for example,

4. Support Netty

5. Handle spaces in tag ex:< head >

6. Add tests for multibyte character encodings, e.g. Chinese

7. Send back trace Id for the server request to the browser, so that you can associate the page to the original request

Doc

  1. Snippet could only be set once, it could not be overwrite once it is set.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 25, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@siyuniu-ms
Copy link
Contributor Author

/easycla

siyuniu-ms and others added 5 commits February 17, 2023 18:36
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
siyuniu-ms and others added 9 commits February 21, 2023 17:48
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
…/opentelemetry/javaagent/instrumentation/servlet/v3_0/snippet/SnippetInjectingResponseWrapper.java

Co-authored-by: Trask Stalnaker <[email protected]>
Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

🥳

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 19, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 20, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@trask trask merged commit c7bd3e4 into open-telemetry:main Apr 26, 2023
@trask
Copy link
Member

trask commented Apr 26, 2023

thx @siyuniu-ms 💯

@laurit
Copy link
Contributor

laurit commented Apr 27, 2023

@siyuniu-ms this pr introduces flaky test https://ge.opentelemetry.io/scans/tests?search.buildOutcome=success&search.tags=CI&search.timeZoneId=Europe/Tallinn&tests.sortField=FLAKY&tests.unstableOnly=true please fix

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.

None yet

4 participants