-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DelayedAttributes and LateBoundSampler
- Loading branch information
Showing
16 changed files
with
327 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ent/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetrySamplerConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.quarkus.opentelemetry.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.sdk.trace.samplers.Sampler; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class OpenTelemetrySamplerConfigTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.sampler", "traceidratio") | ||
.overrideConfigKey("quarkus.opentelemetry.tracer.sampler.ratio", "0.5") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClass(TestUtil.class)); | ||
|
||
@Inject | ||
OpenTelemetry openTelemetry; | ||
|
||
@Test | ||
void test() throws NoSuchFieldException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { | ||
Sampler sampler = TestUtil.getSampler(openTelemetry); | ||
|
||
assertEquals(String.format("TraceIdRatioBased{%.6f}", 0.5d), sampler.getDescription()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...emetry/opentelemetry/deployment/src/test/resources/resource-config/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.application.name=resource-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...try/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DelayedAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.quarkus.opentelemetry.runtime.tracing; | ||
|
||
import java.util.Map; | ||
import java.util.function.BiConsumer; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
|
||
public class DelayedAttributes implements Attributes { | ||
private Attributes delegate; | ||
|
||
public void setAttributesDelegate(Attributes delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public <T> T get(AttributeKey<T> attributeKey) { | ||
return delegate.get(attributeKey); | ||
} | ||
|
||
@Override | ||
public void forEach(BiConsumer<? super AttributeKey<?>, ? super Object> biConsumer) { | ||
delegate.forEach(biConsumer); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return delegate.size(); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return delegate.isEmpty(); | ||
} | ||
|
||
@Override | ||
public Map<AttributeKey<?>, Object> asMap() { | ||
return delegate.asMap(); | ||
} | ||
|
||
@Override | ||
public AttributesBuilder toBuilder() { | ||
return delegate.toBuilder(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...etry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/LateBoundSampler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.opentelemetry.runtime.tracing; | ||
|
||
import java.util.List; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.trace.SpanKind; | ||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.sdk.trace.data.LinkData; | ||
import io.opentelemetry.sdk.trace.samplers.Sampler; | ||
import io.opentelemetry.sdk.trace.samplers.SamplingResult; | ||
|
||
public class LateBoundSampler implements Sampler { | ||
private Sampler delegate; | ||
|
||
public void setSamplerDelegate(Sampler delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public SamplingResult shouldSample(Context parentContext, | ||
String traceId, | ||
String name, | ||
SpanKind spanKind, | ||
Attributes attributes, | ||
List<LinkData> parentLinks) { | ||
return delegate.shouldSample(parentContext, traceId, name, spanKind, attributes, parentLinks); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return delegate.getDescription(); | ||
} | ||
} |
Oops, something went wrong.