@Test public void sendWithBasicAuth() throws Exception { System.setProperty(Configuration.JAEGER_ENDPOINT, target("/api/basic-auth").getUri().toString()); System.setProperty(Configuration.JAEGER_USER, "jdoe"); System.setProperty(Configuration.JAEGER_PASSWORD, "password"); HttpSender sender = (HttpSender) Configuration.SenderConfiguration.fromEnv().getSender(); sender.send(new Process("robotrock"), generateSpans()); }
@Override public void send(Process process, List<Span> spans) throws SenderException { Batch batch = new Batch(process, spans); byte[] bytes = null; try { bytes = serialize(batch); } catch (Exception e) { throw new SenderException(String.format("Failed to serialize %d spans", spans.size()), e, spans.size()); } RequestBody body = RequestBody.create(MEDIA_TYPE_THRIFT, bytes); Request request = requestBuilder.post(body).build(); Response response; try { response = httpClient.newCall(request).execute(); } catch (IOException e) { throw new SenderException(String.format("Could not send %d spans", spans.size()), e, spans.size()); } if (response.isSuccessful()) { response.close(); return; } String responseBody; try { responseBody = response.body() != null ? response.body().string() : "null"; } catch (IOException e) { responseBody = "unable to read response"; } String exceptionMessage = String.format("Could not send %d spans, response %d: %s", spans.size(), response.code(), responseBody); throw new SenderException(exceptionMessage, null, spans.size()); }
HttpSender extends ThriftSender { @Override public void send(Process process, List<Span> spans) throws SenderException { Batch batch = new Batch(process, spans); byte[] bytes = null; try { bytes = serialize(batch); } catch (Exception e) { throw new SenderException(String.format("Failed to serialize %d spans", spans.size()), e, spans.size()); } RequestBody body = RequestBody.create(MEDIA_TYPE_THRIFT, bytes); Request request = requestBuilder.post(body).build(); Response response; try { response = httpClient.newCall(request).execute(); } catch (IOException e) { throw new SenderException(String.format("Could not send %d spans", spans.size()), e, spans.size()); } if (response.isSuccessful()) { response.close(); return; } String responseBody; try { responseBody = response.body() != null ? response.body().string() : "null"; } catch (IOException e) { responseBody = "unable to read response"; } String exceptionMessage = String.format("Could not send %d spans, response %d: %s", spans.size(), response.code(), responseBody); throw new SenderException(exceptionMessage, null, spans.size()); } }
HttpSender extends ThriftSender { @Override public void send(Process process, List<Span> spans) throws SenderException { Batch batch = new Batch(process, spans); byte[] bytes = null; try { bytes = serialize(batch); } catch (Exception e) { throw new SenderException(String.format("Failed to serialize %d spans", spans.size()), e, spans.size()); } RequestBody body = RequestBody.create(MEDIA_TYPE_THRIFT, bytes); Request request = requestBuilder.post(body).build(); Response response; try { response = httpClient.newCall(request).execute(); } catch (IOException e) { throw new SenderException(String.format("Could not send %d spans", spans.size()), e, spans.size()); } if (response.isSuccessful()) { response.close(); return; } String responseBody; try { responseBody = response.body() != null ? response.body().string() : "null"; } catch (IOException e) { responseBody = "unable to read response"; } String exceptionMessage = String.format("Could not send %d spans, response %d: %s", spans.size(), response.code(), responseBody); throw new SenderException(exceptionMessage, null, spans.size()); } protected  HttpSender(Builder builder); }
HttpSender extends ThriftSender { @Override public void send(Process process, List<Span> spans) throws SenderException { Batch batch = new Batch(process, spans); byte[] bytes = null; try { bytes = serialize(batch); } catch (Exception e) { throw new SenderException(String.format("Failed to serialize %d spans", spans.size()), e, spans.size()); } RequestBody body = RequestBody.create(MEDIA_TYPE_THRIFT, bytes); Request request = requestBuilder.post(body).build(); Response response; try { response = httpClient.newCall(request).execute(); } catch (IOException e) { throw new SenderException(String.format("Could not send %d spans", spans.size()), e, spans.size()); } if (response.isSuccessful()) { response.close(); return; } String responseBody; try { responseBody = response.body() != null ? response.body().string() : "null"; } catch (IOException e) { responseBody = "unable to read response"; } String exceptionMessage = String.format("Could not send %d spans, response %d: %s", spans.size(), response.code(), responseBody); throw new SenderException(exceptionMessage, null, spans.size()); } protected  HttpSender(Builder builder); @Override void send(Process process, List<Span> spans); }
HttpSender extends ThriftSender { @Override public void send(Process process, List<Span> spans) throws SenderException { Batch batch = new Batch(process, spans); byte[] bytes = null; try { bytes = serialize(batch); } catch (Exception e) { throw new SenderException(String.format("Failed to serialize %d spans", spans.size()), e, spans.size()); } RequestBody body = RequestBody.create(MEDIA_TYPE_THRIFT, bytes); Request request = requestBuilder.post(body).build(); Response response; try { response = httpClient.newCall(request).execute(); } catch (IOException e) { throw new SenderException(String.format("Could not send %d spans", spans.size()), e, spans.size()); } if (response.isSuccessful()) { response.close(); return; } String responseBody; try { responseBody = response.body() != null ? response.body().string() : "null"; } catch (IOException e) { responseBody = "unable to read response"; } String exceptionMessage = String.format("Could not send %d spans, response %d: %s", spans.size(), response.code(), responseBody); throw new SenderException(exceptionMessage, null, spans.size()); } protected  HttpSender(Builder builder); @Override void send(Process process, List<Span> spans);  }