DatadogTransportSerializer implements TransportSerializer { @Override public byte[] serialize(InternalEvent event) { StringBuilder payload = new StringBuilder(); payload.append(apiKey); payload.append(' '); payload.append(event.getSerialized()); payload.append('\n'); return payload.toString().getBytes(); } DatadogTransportSerializer(ValueConfig<?> apiKey); @Override byte[] serialize(InternalEvent event);  }
@Test public void shouldSerialize() { StringValueConfig apiKey = new StringValueConfig("foo"); DatadogTransportSerializer serializer = new DatadogTransportSerializer(apiKey); InternalEvent record = new InternalEvent("", null, 0); record.setEventTime(1521645289128L); record.setSerialized("bar"); String actual = new String(serializer.serialize(record), StandardCharsets.UTF_8); assertEquals("foo bar\n", actual); }