Skip to content

Commit

Permalink
Set response type and minor restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeagher committed Oct 11, 2024
1 parent 6d76385 commit 703400d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions receiver/datadogreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,21 @@ func (ddr *datadogReceiver) handleTraces(w http.ResponseWriter, req *http.Reques
}
}

responseBody := "OK"
contentType := "text/plain"
urlSplit := strings.Split(req.RequestURI, "/")
if len(urlSplit) == 3 {
// Match the response logic from dd-agent https://github.com/DataDog/datadog-agent/blob/86b2ae24f93941447a5bf0a2b6419caed77e76dd/pkg/trace/api/api.go#L511-L519
switch version := urlSplit[1]; version {
case "v0.1", "v0.2", "v0.3":
_, _ = w.Write([]byte("OK"))
// Keep the "OK" response for these versions
default:
_, _ = w.Write([]byte("{}"))
contentType = "application/json"
responseBody = "{}"
}
} else {
_, _ = w.Write([]byte("OK"))
}
w.Header().Set("Content-Type", contentType)
_, _ = w.Write([]byte(responseBody))
}

// handleV1Series handles the v1 series endpoint https://docs.datadoghq.com/api/latest/metrics/#submit-metrics
Expand Down

0 comments on commit 703400d

Please sign in to comment.