Skip to content

Commit d3affde

Browse files
committed
extra defensive coding
1 parent 03db92f commit d3affde

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

receiver/datadogreceiver/receiver.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,17 @@ func (ddr *datadogReceiver) handleTraces(w http.ResponseWriter, req *http.Reques
245245
}
246246

247247
urlSplit := strings.Split(req.RequestURI, "/")
248-
switch version := urlSplit[1]; version {
249-
case "v0.1", "v0.2", "v0.3":
248+
if len(urlSplit) == 3 {
249+
// Match the response logic from dd-agent https://github.com/DataDog/datadog-agent/blob/86b2ae24f93941447a5bf0a2b6419caed77e76dd/pkg/trace/api/api.go#L511-L519
250+
switch version := urlSplit[1]; version {
251+
case "v0.1", "v0.2", "v0.3":
252+
_, _ = w.Write([]byte("OK"))
253+
default:
254+
_, _ = w.Write([]byte("{}"))
255+
}
256+
} else {
250257
_, _ = w.Write([]byte("OK"))
251-
default:
252-
_, _ = w.Write([]byte("{}"))
253258
}
254-
255259
}
256260

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

0 commit comments

Comments
 (0)