@Test protected void getTraces_differentiateOnServiceName(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);

    Span trace1 = Span.newBuilder().traceId(newTraceId()).name("1").id(1)
      .kind(CLIENT)
      .timestamp((TODAY + 1) * 1000L)
      .duration(3000L)
      .localEndpoint(frontend)
      .addAnnotation(((TODAY + 1) * 1000L) + 500, "web")
      .putTag("local", "web")
      .putTag("web-b", "web")
      .build();

    Span trace1Server = Span.newBuilder().traceId(trace1.traceId()).name("1").id(1)
      .kind(SERVER)
      .shared(true)
      .localEndpoint(backend)
      .timestamp((TODAY + 2) * 1000L)
      .duration(1000L)
      .build();

    Span trace2 = Span.newBuilder().traceId(newTraceId()).name("2").id(2)
      .timestamp((TODAY + 11) * 1000L)
      .duration(3000L)
      .kind(CLIENT)
      .localEndpoint(backend)
      .addAnnotation(((TODAY + 11) * 1000) + 500, "app")
      .putTag("local", "app")
      .putTag("app-b", "app")
      .build();

    Span trace2Server = Span.newBuilder().traceId(trace2.traceId()).name("2").id(2)
      .shared(true)
      .kind(SERVER)
      .localEndpoint(frontend)
      .timestamp((TODAY + 12) * 1000L)
      .duration(1000L).build();

    accept(trace1, trace1Server, trace2, trace2Server);

    // Sanity check
    assertGetTraceReturns(trace1.traceId(), List.of(trace1, trace1Server));
    assertGetTraceReturns(trace2.traceId(), List.of(trace2, trace2Server));
    assertGetTracesReturns(requestBuilder().build(),
      List.of(trace1, trace1Server), List.of(trace2, trace2Server));

    // We only return traces where the service specified caused the data queried.
    assertGetTracesReturns(
      requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("web").build(),
      List.of(trace1, trace1Server));

    assertGetTracesReturnsEmpty(
      requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("web").build());

    assertGetTracesReturns(
      requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("app").build(),
      List.of(trace2, trace2Server));

    assertGetTracesReturnsEmpty(
      requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("app").build());

    // tags are returned on annotation queries
    assertGetTracesReturns(
      requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("web-b").build(),
      List.of(trace1, trace1Server));

    assertGetTracesReturnsEmpty(
      requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("web-b").build());

    assertGetTracesReturns(
      requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("app-b").build(),
      List.of(trace2, trace2Server));

    assertGetTracesReturnsEmpty(
      requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("app-b").build());

    // We only return traces where the service specified caused the tag queried.
    assertGetTracesReturns(
      requestBuilder().serviceName(frontend.serviceName())
        .parseAnnotationQuery("local=web")
        .build(),
      List.of(trace1, trace1Server));

    assertGetTracesReturnsEmpty(
      requestBuilder().serviceName(backend.serviceName())
        .parseAnnotationQuery("local=web")
        .build());

    assertGetTracesReturns(
      requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("local=app").build(),
      List.of(trace2, trace2Server));

    assertGetTracesReturnsEmpty(
      requestBuilder().serviceName(frontend.serviceName())
        .parseAnnotationQuery("local=app")
        .build());
  }
This test makes sure that annotation queries pay attention to which host recorded data
zipkin-tests/src/main/java/zipkin2/storage/ITSpanStore.java