public <T> OutputSampler<T> sampleOutput(String pcollectionId, Coder<T> coder) {
    return (OutputSampler<T>)
        outputSamplers.computeIfAbsent(
            pcollectionId,
            k ->
                new OutputSampler<>(
                    coder, this.maxSamples, this.sampleEveryN, this.onlySampleExceptions));
  }
@Test
  public void testNestedContext() throws Exception {
    DataSampler sampler = new DataSampler();

    String rawString = "hello";
    byte[] byteArray = rawString.getBytes(StandardCharsets.US_ASCII);
    ByteArrayCoder coder = ByteArrayCoder.of();
    sampler.sampleOutput("pcollection-id", coder).sample(globalWindowedValue(byteArray));

    BeamFnApi.InstructionResponse samples = getAllSamples(sampler);
    assertHasSamples(samples, "pcollection-id", Collections.singleton(encodeByteArray(byteArray)));
  }