11package datadog .communication .ddagent ;
22
3+ import static datadog .communication .serialization .msgpack .MsgPackWriter .FIXARRAY ;
4+ import static java .util .Collections .singletonList ;
5+
36import com .squareup .moshi .JsonAdapter ;
47import com .squareup .moshi .Moshi ;
58import com .squareup .moshi .Types ;
1114import datadog .trace .util .Strings ;
1215import java .nio .ByteBuffer ;
1316import java .security .NoSuchAlgorithmException ;
14- import java .util .Collections ;
1517import java .util .HashSet ;
1618import java .util .List ;
1719import java .util .Map ;
@@ -32,6 +34,12 @@ public class DDAgentFeaturesDiscovery implements DroppingPolicy {
3234 .build ()
3335 .adapter (Types .newParameterizedType (Map .class , String .class , Object .class ));
3436
37+ // Currently all the endpoints that we probe expect a msgpack body of an array of arrays, v3/v4
38+ // arbitrary size and v5 two elements, so let's give them a two element array of empty arrays
39+ private static final byte [] PROBE_MESSAGE = {
40+ (byte ) FIXARRAY | 2 , (byte ) FIXARRAY , (byte ) FIXARRAY
41+ };
42+
3543 public static final String V3_ENDPOINT = "v0.3/traces" ;
3644 public static final String V4_ENDPOINT = "v0.4/traces" ;
3745 public static final String V5_ENDPOINT = "v0.5/traces" ;
@@ -191,7 +199,9 @@ private String probeTracesEndpoint(String[] endpoints) {
191199 client
192200 .newCall (
193201 new Request .Builder ()
194- .put (OkHttpUtils .msgpackRequestBodyOf (Collections .<ByteBuffer >emptyList ()))
202+ .put (
203+ OkHttpUtils .msgpackRequestBodyOf (
204+ singletonList (ByteBuffer .wrap (PROBE_MESSAGE ))))
195205 .url (agentBaseUrl .resolve (candidate ))
196206 .build ())
197207 .execute ()) {
0 commit comments