Apply default decorators in unit tests
This commit is contained in:
parent
7920cc9d8e
commit
13b0df8aca
|
@ -1,17 +1,26 @@
|
|||
package datadog.trace.agent.test;
|
||||
|
||||
import datadog.opentracing.DDTracer;
|
||||
import datadog.opentracing.decorators.AbstractDecorator;
|
||||
import datadog.opentracing.decorators.DBTypeDecorator;
|
||||
import datadog.opentracing.decorators.DDDecoratorsFactory;
|
||||
import datadog.trace.agent.tooling.AgentInstaller;
|
||||
import datadog.trace.agent.tooling.Instrumenter;
|
||||
import datadog.trace.common.writer.ListWriter;
|
||||
|
||||
import io.opentracing.Tracer;
|
||||
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.util.List;
|
||||
|
||||
import net.bytebuddy.agent.ByteBuddyAgent;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.spockframework.runtime.model.SpecMetadata;
|
||||
|
||||
import spock.lang.Specification;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +54,11 @@ public abstract class AgentTestRunner extends Specification {
|
|||
static {
|
||||
TEST_WRITER = new ListWriter();
|
||||
TEST_TRACER = new DDTracer(TEST_WRITER);
|
||||
|
||||
final List<AbstractDecorator> decorators = DDDecoratorsFactory.createFromResources();
|
||||
for (final AbstractDecorator decorator : decorators) {
|
||||
((DDTracer) TEST_TRACER).addDecorator(decorator);
|
||||
}
|
||||
ByteBuddyAgent.install();
|
||||
instrumentation = ByteBuddyAgent.getInstrumentation();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# Decorators are used to add extra information to span
|
||||
# Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator
|
||||
decorators:
|
||||
- type: HTTPComponent
|
||||
matchingValue: java-okhttp
|
||||
setValue: http-client
|
||||
- type: HTTPComponent
|
||||
matchingValue: java-aws-sdk
|
||||
setValue: aws-client
|
||||
- type: ErrorFlag
|
||||
- type: DBTypeDecorator
|
||||
- type: DBStatementAsResourceName
|
||||
- type: OperationDecorator
|
||||
- type: Status404Decorator
|
||||
- type: URLAsResourceName
|
Loading…
Reference in New Issue