← Back to Pull requests

docs(rum): explain that compressed HTML is not injected #503

Merged
iamluc merged 1 files (60 lines) on Nov 26, 2026 08:13 UTC
View on GitHub
iamluc iamluc commented on Nov 25, 2026 09:49 UTC
Author

Overview

Document that RUM injection is skipped when the HTML response already has a Content-Encoding
header, and how to work around it: ask the backend for uncompressed HTML
(proxy_set_header Accept-Encoding "";) and let Nginx compress it (gzip on;).

Motivation

Users with a backend that gzips HTML get no injection and do not know why.

Additional Notes

Tested in Docker with the module built from master (RUM=ON NGINX_VERSION=1.31.10 make build-musl,
image nginx:1.31.10-alpine), a backend that gzips HTML only when asked, and a client sending
Accept-Encoding: gzip:

  • Without the workaround: backend returns gzip, no injection, log

  • RUM SDK injection skipped: compressed html content.
  • With the documented location block: backend receives an empty Accept-Encoding, the client

  • gets Content-Encoding: gzip, and the decompressed body contains the RUM snippet.
  • nginx-debug logs show the Datadog body filter runs before http gzip filter.
  • References

    Jira ticket: INPLAT-1455

    Contributor Checklist

  • I am the author of this pull request and I own it.

  • I reviewed every line of this pull request.

  • This pull request follows the Contributing Guidelines.
  • Diff: 60 lines (+60 / -0) across 1 files Reviewer: pawelchcki Review duration: 1344m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.28) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.28 · 60 lines diff across 1 files
    0.28
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.85 · 5 substantive comment(s)
    0.85
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.246
    Real PR Conversation Timeline
    13 items
    datadog-prod-us1-3[bot] datadog-prod-us1-3[bot] commented on Nov 25, 2026 10:22 UTC
    Bot

    <a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40git.commit.sha%3A38fb95d875740042fc97afcdf88e852fd0a5fe56&referrer=pr-comment&start=1795677326000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok-light.svg" alt="Pipelines" align="center" /></picture></a> &nbsp;<a target='_blank' href='https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest+%40git.commit.sha%3A0b91c99feae3dca5548b11bc2805211b0c466a96&referrer=pr-comment&start=1795677326000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-ok-light.svg" alt="Tests" align="center" /></picture></a>

    <details><summary><b>🎉 All green!</b></summary>

    🧪 All tests passed
    ❄️ No new flaky tests detected
    </details>

    🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fnginx-datadog/pull-requests/503'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 100.00%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 70.11% <span title="Change in overall coverage compared to the base branch">(+0.00%)</span><br>

    <sub>
    This comment will be updated automatically if new data arrives. <br />
    🔗 Commit SHA: 38fb95d | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL25naW54LWRhdGFkb2cvNTAz?referrer=pr-comment">View more details</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
    </sub>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 25, 2026 12:44 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"fc0680f9d760fa01f39bd5e31e034f5c2e8c5247","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":"fc0680f9d760fa01f39bd5e31e034f5c2e8c5247","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} -->
    <!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"fc0680f9d760fa01f39bd5e31e034f5c2e8c5247","mergeGateEnabled":false,"pullRequestNumber":503,"repository":"DataDog/nginx-datadog","status":"completed"} -->
    <details>
    <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-25T12:44:51.460351Z">2026-11-25T12:44:51.460351Z</relative-time> | fc0680f | Draft marked ready |
    | 🔒 Security Review | ✅ Completed <relative-time datetime="2026-11-25T12:47:19.653174Z">2026-11-25T12:47:19.653174Z</relative-time> | fc0680f | Draft marked ready |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    </details>

    pawelchcki pawelchcki approved these changes on Nov 25, 2026 13:06 UTC
    Approved Reviewer

    Approved these changes.

    xlamorlette-datadog xlamorlette-datadog commented on code on Nov 25, 2026 15:14 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)

    _nit_:

  • instead of “RUM builds”, maybe rather “RUM variant” or ”RUM flavor”

  • introduce an acronym by its full meaning
  • So that _could_ be:

    ## Real User Monitoring (RUM) Injection
    
    The RUM flavor of the Datadog Nginx module injects the Datadog RUM Browser SDK…
    

    xlamorlette-datadog xlamorlette-datadog commented on code on Nov 25, 2026 15:14 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)
    +
    +RUM builds inject the Datadog RUM Browser SDK into HTML responses. The injection is controlled by
    +the `datadog_rum` and `datadog_rum_config` directives.
    +
    +### Compressed responses

    _nit_: capitalize titles

    xlamorlette-datadog xlamorlette-datadog commented on code on Nov 25, 2026 15:32 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)
    +
    +RUM builds inject the Datadog RUM Browser SDK into HTML responses. The injection is controlled by
    +the `datadog_rum` and `datadog_rum_config` directives.

    Maybe document each of these two directives with a (small) dedicated section, as the other directives listed in the file.

    xlamorlette-datadog xlamorlette-datadog commented on code on Nov 25, 2026 15:35 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)
    +
    +RUM builds inject the Datadog RUM Browser SDK into HTML responses. The injection is controlled by
    +the `datadog_rum` and `datadog_rum_config` directives.
    +
    +### Compressed responses
    +
    +The SDK is not injected into HTML responses that already have a `Content-Encoding` header, such
    +as a gzip response from a proxied backend. These responses are sent unchanged, and Nginx logs
    +`RUM SDK injection skipped: compressed html content` at the `info` level.
    +
    +To inject the SDK and still send compressed HTML to the client, ask the backend for uncompressed
    +HTML and let Nginx compress it. The module injects the SDK before the Nginx gzip filter runs.
    +
    +```nginx
    +location / {
    +    proxy_pass http://backend:8080;
    +    proxy_set_header Accept-Encoding "";
    +    gzip on;
    +}
    +```
    +
    +With this setup, the traffic between Nginx and the backend is not compressed. A `proxy_set_header`

    _opt_: maybe use a list:

    With this setup:
    
    - The traffic […]
    - A `proxy_set_header` […]
    - If Nginx […]
    

    xlamorlette-datadog xlamorlette-datadog approved these changes on Nov 25, 2026 15:35 UTC
    Approved Reviewer

    Nice.

    iamluc iamluc commented on code on Nov 26, 2026 07:45 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)

    Done in 38fb95d: the acronym is now spelled out. I kept "RUM builds" to match the "(AppSec builds)" wording used in the rest of the file.

    iamluc iamluc commented on code on Nov 26, 2026 07:45 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)
    +
    +RUM builds inject the Datadog RUM Browser SDK into HTML responses. The injection is controlled by
    +the `datadog_rum` and `datadog_rum_config` directives.
    +
    +### Compressed responses

    Done in 38fb95d.

    iamluc iamluc commented on code on Nov 26, 2026 07:45 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)
    +
    +RUM builds inject the Datadog RUM Browser SDK into HTML responses. The injection is controlled by
    +the `datadog_rum` and `datadog_rum_config` directives.

    Done in 38fb95d: added small sections for datadog_rum and datadog_rum_config.

    iamluc iamluc commented on code on Nov 26, 2026 07:45 UTC
    Code Review
    doc/configuration.md:1
    @@ -448,6 +448,33 @@ output filter chain before a decision can be made. This setting controls the app
     amount of memory that will be allocated in the interim. Beyond this, the ouput filter chain will
     stall. Note that Nginx may still spill the response into a temporary file if configured to do so.
     
    +## RUM Injection (RUM builds)
    +
    +RUM builds inject the Datadog RUM Browser SDK into HTML responses. The injection is controlled by
    +the `datadog_rum` and `datadog_rum_config` directives.
    +
    +### Compressed responses
    +
    +The SDK is not injected into HTML responses that already have a `Content-Encoding` header, such
    +as a gzip response from a proxied backend. These responses are sent unchanged, and Nginx logs
    +`RUM SDK injection skipped: compressed html content` at the `info` level.
    +
    +To inject the SDK and still send compressed HTML to the client, ask the backend for uncompressed
    +HTML and let Nginx compress it. The module injects the SDK before the Nginx gzip filter runs.
    +
    +```nginx
    +location / {
    +    proxy_pass http://backend:8080;
    +    proxy_set_header Accept-Encoding "";
    +    gzip on;
    +}
    +```
    +
    +With this setup, the traffic between Nginx and the backend is not compressed. A `proxy_set_header`

    Done in 38fb95d.

    Reviewers
    Assignees
    iamluc iamluc
    Labels
    risk: low confidence: 88.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 27.6% (LOW) · Higher = larger blast radius
    27.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88.3% · Lower = rushed or shallow review
    88.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.2% · Safe to merge
    3.2%