Skip to content

Commit 4f37cae

Browse files
traskbreedx-splk
andauthored
Document snippet option (#14263)
Co-authored-by: jason plumb <[email protected]>
1 parent 875a4db commit 4f37cae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/advanced-configuration-options.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,22 @@ This option can be used to let agent run with all privileges without being affec
3636

3737
[1] Disclaimer: agent can provide application means for escaping security manager sandbox. Do not use
3838
this option if your application relies on security manager to run untrusted code.
39+
40+
## JavaScript snippet injection
41+
42+
This experimental feature allows you to inject JavaScript code into HTML responses from servlet applications. The agent will look for the `</head>` tag in HTML responses, and inject the configured JavaScript snippet before the closing `</head>` tag.
43+
44+
This feature is designed for integrating client-side monitoring.
45+
We plan to integrate OpenTelemetry's own client-side monitoring solution by default once it's available
46+
(see the [browser instrumentation proposal](https://github.com/open-telemetry/community/blob/main/projects/browser-phase-1.md)).
47+
48+
| System property | Environment variable | Purpose |
49+
|-----------------------------------------|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
50+
| otel.experimental.javascript-snippet | OTEL_EXPERIMENTAL_JAVASCRIPT_SNIPPET | JavaScript code to inject into HTML responses before the closing `</head>` tag. The value should be a complete JavaScript snippet including `<script>` tags if needed, e.g. `-Dotel.experimental.javascript-snippet="<script>console.log('Hello world!');</script>"` |
51+
52+
**Important notes:**
53+
54+
- This only works with servlet-based applications currently
55+
- The snippet is injected only into HTML responses that contain a `</head>` tag
56+
- The agent will attempt to preserve the original character encoding of the response
57+
- If the response already has a `Content-Length` header, it will be updated to reflect the additional content

0 commit comments

Comments
 (0)