Support legacy datadog agent (#2670)

dd-agent v5 can issue some requests with trailing slashes.
(e.g.
526559be73/ddagent.py (L303))
Trim trailing slashes for request on /datadog/ paths to accomodate for
that.

Co-authored-by: Pierre Rossi <pierre.rossi@schibsted.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
elProxy 2022-06-07 14:06:18 +02:00 committed by GitHub
parent b022f1f113
commit e755d0ec3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,6 +107,9 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
defer requestDuration.UpdateDuration(startTime)
path := strings.Replace(r.URL.Path, "//", "/", -1)
if strings.HasPrefix(path, "/datadog") {
path = strings.TrimSuffix(path, "/")
}
if strings.HasPrefix(path, "/static") {
staticServer.ServeHTTP(w, r)
return true