@Theory
  public void monitorsWithAnnotations() throws Exception {
    FakeMonitoringClient fakeMonitoringClient = new FakeMonitoringClient();
    MutableMonitoringRegistry.globalInstance().clear();
    MutableMonitoringRegistry.globalInstance().registerMonitoringClient(fakeMonitoringClient);
    PublicKeySignWrapper.register();

    MonitoringAnnotations annotations =
        MonitoringAnnotations.newBuilder().add("annotation_name", "annotation_value").build();
    EcdsaParameters parameters =
        EcdsaParameters.builder()
            .setSignatureEncoding(EcdsaParameters.SignatureEncoding.IEEE_P1363)
            .setCurveType(EcdsaParameters.CurveType.NIST_P256)
            .setHashType(EcdsaParameters.HashType.SHA256)
            .setVariant(EcdsaParameters.Variant.TINK)
            .build();

    KeysetHandle handle =
        KeysetHandle.newBuilder()
            .addEntry(
                KeysetHandle.generateEntryFromParameters(parameters).withFixedId(123).makePrimary())
            .setMonitoringAnnotations(annotations)
            .build();

    PublicKeySign signer = handle.getPrimitive(PublicKeySign.class);
    byte[] data = "data".getBytes(UTF_8);
    Object unused = signer.sign(data);

    List<FakeMonitoringClient.LogEntry> logEntries = fakeMonitoringClient.getLogEntries();
    assertThat(logEntries).hasSize(1);
    FakeMonitoringClient.LogEntry signEntry = logEntries.get(0);
    assertThat(signEntry.getKeyId()).isEqualTo(123);
    assertThat(signEntry.getPrimitive()).isEqualTo("public_key_sign");
    assertThat(signEntry.getApi()).isEqualTo("sign");
    assertThat(signEntry.getNumBytesAsInput()).isEqualTo(data.length);
    assertThat(signEntry.getKeysetInfo().getAnnotations()).isEqualTo(annotations);
  }
We test all variants for legacy reasons.
java_src/src/test/java/com/google/crypto/tink/signature/PublicKeySignWrapperTest.java