public static void main()

in sample-apps/jaeger-zipkin-sample-app/src/main/java/com/amazon/sampleapp/App.java [36:110]


  public static void main(String[] args) throws Exception {

    // initialize Jaeger trace emitter client
    String collectorUrl = System.getenv("JAEGER_RECEIVER_ENDPOINT");
    if (collectorUrl == null) {
      collectorUrl = "0.0.0.0:14268";
    }
    TraceClient jaegerClient = new JaegerTraceEmitClient(collectorUrl);

    // initialize Jaeger trace emitter client
    collectorUrl = System.getenv("ZIPKIN_RECEIVER_ENDPOINT");
    if (collectorUrl == null) {
      collectorUrl = "0.0.0.0:9411";
    }
    TraceClient zipkinClient = new ZipkinTraceEmitClient(collectorUrl);

    final Call.Factory httpClient = new OkHttpClient();
    String port;
    String host;
    String listenAddress = System.getenv("LISTEN_ADDRESS");

    if (listenAddress == null) {
      host = "127.0.0.1";
      port = "4567";
    } else {
      String[] splitAddress = listenAddress.split(":");
      host = splitAddress[0];
      port = splitAddress[1];
    }

    // set sampleapp app port number and ip address
    port(Integer.parseInt(port));
    ipAddress(host);

    get(
        "/",
        (req, res) -> {
          return "healthcheck";
        });

    /** zipkin trace request */
    get(
        "/outgoing-zipkin-http-call",
        (req, res) -> {
          String traceId;
          try {
            traceId = zipkinClient.emit();
          } catch (IOException e) {
            throw new UncheckedIOException("Could not fetch endpoint", e);
          }

          return String.format("{\"traceId\": \"%s\"}", traceId);
        });

    /** jaeger trace request */
    get(
        "/outgoing-jaeger-http-call",
        (req, res) -> {
          String traceId;
          try {
            traceId = jaegerClient.emit();
          } catch (IOException e) {
            throw new UncheckedIOException("Could not fetch endpoint", e);
          }

          return String.format("{\"traceId\": \"%s\"}", traceId);
        });

    exception(
        Exception.class,
        (exception, request, response) -> {
          // Handle the exception here
          exception.printStackTrace();
        });
  }