Skip to content

refactor(api): replace gorilla/mux with net/http across agent servers#50380

Draft
pgimalac wants to merge 1 commit intomainfrom
pgimalac/gorilla-mux-pr12
Draft

refactor(api): replace gorilla/mux with net/http across agent servers#50380
pgimalac wants to merge 1 commit intomainfrom
pgimalac/gorilla-mux-pr12

Conversation

@pgimalac
Copy link
Copy Markdown
Member

@pgimalac pgimalac commented May 5, 2026

What does this PR do?

Replaces github.com/gorilla/mux (and gorilla/handlers) with the standard library net/http across most of the agent's HTTP servers. Second step in the series to remove gorilla entirely — follow-up to #50275.

Not included: cmd/system-probe (module router needs an API redesign) and comp/core/gui (auth middleware scoping needs a design decision). Those are the last two remaining uses.

Motivation

gorilla/mux has been archived since 2023. Go 1.22+ net/http covers everything we use.

Describe how you validated your changes

Builds pass for agent, cluster-agent, security-agent, and process-agent. Unit tests pass. Pre-push linter and test hooks pass.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 5, 2026

Go Package Import Differences

Baseline: ed51e26
Comparison: dfd5a19

binaryosarchchange
heroku-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/api/middleware
cluster-agentlinuxamd64
+1, -2
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/gorilla/handlers
-github.com/gorilla/mux
cluster-agentlinuxarm64
+1, -2
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/gorilla/handlers
-github.com/gorilla/mux
cluster-agent-cloudfoundrylinuxamd64
+1, -3
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/felixge/httpsnoop
-github.com/gorilla/handlers
-github.com/gorilla/mux
cluster-agent-cloudfoundrylinuxarm64
+1, -3
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/felixge/httpsnoop
-github.com/gorilla/handlers
-github.com/gorilla/mux
dogstatsdlinuxamd64
+0, -1
-github.com/gorilla/mux
dogstatsdlinuxarm64
+0, -1
-github.com/gorilla/mux
process-agentlinuxamd64
+0, -1
-github.com/gorilla/mux
process-agentlinuxarm64
+0, -1
-github.com/gorilla/mux
process-agentwindowsamd64
+0, -1
-github.com/gorilla/mux
process-agentdarwinamd64
+0, -1
-github.com/gorilla/mux
process-agentdarwinarm64
+0, -1
-github.com/gorilla/mux
heroku-process-agentlinuxamd64
+0, -1
-github.com/gorilla/mux
security-agentlinuxamd64
+0, -1
-github.com/gorilla/mux
security-agentlinuxarm64
+0, -1
-github.com/gorilla/mux
security-agentwindowsamd64
+0, -1
-github.com/gorilla/mux
host-profilerlinuxamd64
+0, -1
-github.com/gorilla/mux
host-profilerlinuxarm64
+0, -1
-github.com/gorilla/mux
installerlinuxamd64
+1, -1
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/gorilla/mux
installerlinuxarm64
+1, -1
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/gorilla/mux
installerwindowsamd64
+1, -1
+github.com/DataDog/datadog-agent/pkg/api/middleware
-github.com/gorilla/mux
privateactionrunnerlinuxamd64
+0, -1
-github.com/gorilla/mux
privateactionrunnerlinuxarm64
+0, -1
-github.com/gorilla/mux
privateactionrunnerwindowsamd64
+0, -1
-github.com/gorilla/mux
privateactionrunnerdarwinamd64
+0, -1
-github.com/gorilla/mux
privateactionrunnerdarwinarm64
+0, -1
-github.com/gorilla/mux

@datadog-prod-us1-5
Copy link
Copy Markdown
Contributor

datadog-prod-us1-5 Bot commented May 5, 2026

🎯 Code Coverage (details)
Patch Coverage: 32.80%
Overall Coverage: 50.25% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dfd5a19 | Docs | Datadog PR Page | Give us feedback!

@pgimalac pgimalac force-pushed the pgimalac/gorilla-mux-pr12 branch from f12bfd0 to 3d9761e Compare May 6, 2026 13:00
Replaces github.com/gorilla/mux (and gorilla/handlers) with the standard
library net/http across most of the agent's HTTP servers. Second step in
the series to remove gorilla entirely — follow-up to #50275.

Not included: cmd/system-probe (module router requires an API redesign)
and comp/core/gui (auth middleware scoping needs a design decision).
Those are the last two remaining uses.

Changes:
- All servers migrated: agent CMD/IPC, cluster-agent, security-agent,
  process-agent, CLC runner, health probe, settings, status, fleet daemon,
  flare extensions
- gorilla/handlers.RecoveryHandler replaced with pkg/api/middleware
- Fleet daemon Content-Type gate converted to a middleware
- Observability: WrapWithRouteTemplate and MountWithPrefix added to the
  observability package to preserve route-template metric tags across
  sub-mux mounting
- pkg/api/coverage.SetupCoverageHandler updated to accept *http.ServeMux
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 6, 2026

Files inventory check summary

File checks results against ancestor ed51e26c:

Results for datadog-agent_7.80.0~devel.git.512.dfd5a19.pipeline.111745096-1_amd64.deb:

No change detected

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 6, 2026

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor ed51e26
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 -112.5 KiB (0.01% reduction) 742.253 → 742.143 → 750.310
agent_deb_amd64_fips -96.4 KiB (0.01% reduction) 700.315 → 700.221 → 702.690
agent_msi -104.14 KiB (0.02% reduction) 608.024 → 607.923 → 623.540
agent_rpm_amd64 -112.5 KiB (0.01% reduction) 742.236 → 742.126 → 750.280
agent_rpm_amd64_fips -96.4 KiB (0.01% reduction) 700.299 → 700.205 → 702.670
agent_rpm_arm64 -61.57 KiB (0.01% reduction) 720.159 → 720.099 → 724.050
agent_rpm_arm64_fips -93.5 KiB (0.01% reduction) 681.324 → 681.233 → 684.460
agent_suse_amd64 -112.5 KiB (0.01% reduction) 742.236 → 742.126 → 750.280
agent_suse_amd64_fips -96.4 KiB (0.01% reduction) 700.299 → 700.205 → 702.670
agent_suse_arm64 -61.57 KiB (0.01% reduction) 720.159 → 720.099 → 724.050
agent_suse_arm64_fips -93.5 KiB (0.01% reduction) 681.324 → 681.233 → 684.460
docker_agent_amd64 -72.33 KiB (0.01% reduction) 802.491 → 802.420 → 805.870
docker_agent_arm64 -61.41 KiB (0.01% reduction) 805.258 → 805.198 → 809.730
docker_agent_jmx_amd64 -72.34 KiB (0.01% reduction) 993.411 → 993.340 → 996.590
docker_agent_jmx_arm64 -61.41 KiB (0.01% reduction) 984.956 → 984.896 → 989.410
docker_cluster_agent_amd64 -36.1 KiB (0.02% reduction) 206.607 → 206.571 → 207.600
docker_host_profiler_amd64 -98.16 KiB (0.03% reduction) 301.579 → 301.484 → 315.800
docker_host_profiler_arm64 -88.65 KiB (0.03% reduction) 313.059 → 312.972 → 327.400
docker_dogstatsd_amd64 -36.16 KiB (0.09% reduction) 39.496 → 39.460 → 39.540
dogstatsd_deb_amd64 -36.16 KiB (0.12% reduction) 30.149 → 30.114 → 30.770
dogstatsd_deb_arm64 -32.12 KiB (0.11% reduction) 28.279 → 28.247 → 29.270
dogstatsd_rpm_amd64 -36.16 KiB (0.12% reduction) 30.149 → 30.114 → 30.770
dogstatsd_suse_amd64 -36.16 KiB (0.12% reduction) 30.149 → 30.114 → 30.770
iot_agent_deb_amd64 +8.0 KiB (0.02% increase) 44.462 → 44.470 → 44.970
iot_agent_deb_arm64 +4.0 KiB (0.01% increase) 41.442 → 41.446 → 42.560
iot_agent_deb_armhf +4.0 KiB (0.01% increase) 42.183 → 42.186 → 42.740
iot_agent_rpm_amd64 +8.0 KiB (0.02% increase) 44.462 → 44.470 → 44.970
iot_agent_suse_amd64 +8.0 KiB (0.02% increase) 44.462 → 44.470 → 44.970
5 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_heroku_amd64 309.178 MiB
docker_cluster_agent_arm64 220.634 MiB
docker_cws_instrumentation_amd64 7.142 MiB
docker_cws_instrumentation_arm64 6.689 MiB
docker_dogstatsd_arm64 37.690 MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant