@Test
  public void traceSyncAdminEndpoint() throws Exception {
    final Connection connection = connectionRule.getConnection();
    try (final Admin admin = connection.getAdmin()) {
      final TestProtobufRpcProto.BlockingInterface service =
        TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
      final EchoRequestProto request = EchoRequestProto.newBuilder().setMessage("hello").build();
      final String response = TraceUtil.trace(() -> {
        try {
          return service.echo(null, request).getMessage();
        } catch (ServiceException e) {
          throw new RuntimeException(e);
        }
      }, testName.getMethodName());
      assertEquals("hello", response);
    }

    final Matcher<SpanData> parentMatcher = allOf(hasName(testName.getMethodName()), hasEnded());
    waitForAndLog(parentMatcher);
    final List<SpanData> spans = otelClassRule.getSpans();

    final SpanData testSpan =
      spans.stream().filter(parentMatcher::matches).findFirst().orElseThrow(AssertionError::new);
    final Matcher<SpanData> rpcMatcher = allOf(hasName("hbase.pb.MasterService/ExecMasterService"),
      hasParentSpanId(testSpan), hasStatusWithCode(StatusCode.OK));
    assertThat(spans, hasItem(rpcMatcher));
  }
Test cases to verify tracing coprocessor Endpoint execution
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpointTracing.java