Merge pull request #1237 from DataDog/mar-kolya/do-not-create-field-profider-for-all-intrsumentations
Avoid creating context provider for intrumentations that do not need …
This commit is contained in:
commit
27cb2111b6
|
@ -5,6 +5,7 @@ import static net.bytebuddy.matcher.ElementMatchers.any;
|
|||
|
||||
import datadog.trace.agent.tooling.context.FieldBackedProvider;
|
||||
import datadog.trace.agent.tooling.context.InstrumentationContextProvider;
|
||||
import datadog.trace.agent.tooling.context.NoopContextProvider;
|
||||
import datadog.trace.agent.tooling.muzzle.Reference;
|
||||
import datadog.trace.agent.tooling.muzzle.ReferenceMatcher;
|
||||
import datadog.trace.api.Config;
|
||||
|
@ -53,7 +54,11 @@ public interface Instrumenter {
|
|||
instrumentationPrimaryName = instrumentationName;
|
||||
|
||||
enabled = Config.get().isIntegrationEnabled(instrumentationNames, defaultEnabled());
|
||||
contextProvider = new FieldBackedProvider(this);
|
||||
if (contextStore().size() > 0) {
|
||||
contextProvider = new FieldBackedProvider(this);
|
||||
} else {
|
||||
contextProvider = NoopContextProvider.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package datadog.trace.agent.tooling.context;
|
||||
|
||||
import net.bytebuddy.agent.builder.AgentBuilder.Identified.Extendable;
|
||||
|
||||
public class NoopContextProvider implements InstrumentationContextProvider {
|
||||
|
||||
public static NoopContextProvider INSTANCE = new NoopContextProvider();
|
||||
|
||||
private NoopContextProvider() {}
|
||||
|
||||
@Override
|
||||
public Extendable instrumentationTransformer(final Extendable builder) {
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extendable additionalInstrumentation(final Extendable builder) {
|
||||
return builder;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue