RateLimitingSampler implements Sampler { @Override public SamplingStatus sample(String operation, long id) { return SamplingStatus.of(this.rateLimiter.checkCredit(1.0), tags); } RateLimitingSampler(double maxTracesPerSecond); @Override SamplingStatus sample(String operation, long id); @Override boolean equals(Object other); @Override void close(); static final String TYPE; }
@Test public void testTags() { RateLimitingSampler sampler = new RateLimitingSampler(123); Map<String, Object> tags = sampler.sample("operate", 11).getTags(); assertEquals("ratelimiting", tags.get("sampler.type")); assertEquals(123.0, tags.get("sampler.param")); }