class RateLimitingSampler implements Sampler {

  @Override
  public SamplingResult shouldSample(
      SpanContext parentContext,
      String traceId,
      String name,
      Kind spanKind,
      ReadableAttributes attributes,
      List<SpanData.Link> parentLinks) {
    if (parentContext.isSampled()) {
      return Samplers.alwaysOn()
          .shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);
    }
    if (parentLinks != null) {
      for (SpanData.Link parentLink : parentLinks) {
        if (parentLink.getContext().isSampled()) {
          return Samplers.alwaysOn()
              .shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks);
        }
      }
    }
    return this.rateLimiter.checkCredit(1.0) ? onSamplingResult : offSamplingResult;
  }

    RateLimitingSampler(int maxTracesPerSecond);

}