use of io.opentelemetry.instrumentation.api.config.Config in project opentelemetry-java-instrumentation by open-telemetry.
the class TestAgentListener method buildOtherConfiguredIgnores.
private static Trie<IgnoreAllow> buildOtherConfiguredIgnores() {
Config config = Config.builder().build();
IgnoredTypesBuilderImpl builder = new IgnoredTypesBuilderImpl();
for (IgnoredTypesConfigurer configurer : SafeServiceLoader.loadOrdered(IgnoredTypesConfigurer.class)) {
// skip built-in agent ignores
if (configurer instanceof AdditionalLibraryIgnoredTypesConfigurer || configurer instanceof GlobalIgnoredTypesConfigurer) {
continue;
}
configurer.configure(config, builder);
}
return builder.buildIgnoredTypesTrie();
}
use of io.opentelemetry.instrumentation.api.config.Config in project opentelemetry-java-instrumentation by open-telemetry.
the class AgentInstaller method installBytebuddyAgent.
public static void installBytebuddyAgent(Instrumentation inst) {
logVersionInfo();
Config config = Config.get();
if (config.getBoolean(JAVAAGENT_ENABLED_CONFIG, true)) {
setupUnsafe(inst);
List<AgentListener> agentListeners = loadOrdered(AgentListener.class);
installBytebuddyAgent(inst, agentListeners);
} else {
logger.debug("Tracing is disabled, not installing instrumentations.");
}
}
use of io.opentelemetry.instrumentation.api.config.Config in project opentelemetry-java-instrumentation by open-telemetry.
the class AgentInstaller method installBytebuddyAgent.
/**
* Install the core bytebuddy agent along with all implementations of {@link
* InstrumentationModule}.
*
* @param inst Java Instrumentation used to install bytebuddy
* @return the agent's class transformer
*/
public static ResettableClassFileTransformer installBytebuddyAgent(Instrumentation inst, Iterable<AgentListener> agentListeners) {
WeakRefAsyncOperationEndStrategies.initialize();
Config config = Config.get();
setBootstrapPackages(config);
// If noop OpenTelemetry is enabled, autoConfiguredSdk will be null and AgentListeners are not
// called
AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = null;
if (config.getBoolean(JAVAAGENT_NOOP_CONFIG, false)) {
logger.info("Tracing and metrics are disabled because noop is enabled.");
GlobalOpenTelemetry.set(NoopOpenTelemetry.getInstance());
} else {
autoConfiguredSdk = installOpenTelemetrySdk(config);
}
if (autoConfiguredSdk != null) {
runBeforeAgentListeners(agentListeners, config, autoConfiguredSdk);
}
AgentBuilder agentBuilder = new AgentBuilder.Default().disableClassFormatChanges().with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION).with(new RedefinitionDiscoveryStrategy()).with(AgentBuilder.DescriptionStrategy.Default.POOL_ONLY).with(AgentTooling.poolStrategy()).with(new ClassLoadListener()).with(AgentTooling.locationStrategy(Utils.getBootstrapProxy()));
if (JavaModule.isSupported()) {
agentBuilder = agentBuilder.with(new ExposeAgentBootstrapListener(inst));
}
agentBuilder = configureIgnoredTypes(config, agentBuilder);
if (logger.isDebugEnabled()) {
agentBuilder = agentBuilder.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION).with(new RedefinitionDiscoveryStrategy()).with(new RedefinitionLoggingListener()).with(new TransformLoggingListener());
}
int numberOfLoadedExtensions = 0;
for (AgentExtension agentExtension : loadOrdered(AgentExtension.class)) {
logger.debug("Loading extension {} [class {}]", agentExtension.extensionName(), agentExtension.getClass().getName());
try {
agentBuilder = agentExtension.extend(agentBuilder);
numberOfLoadedExtensions++;
} catch (Exception | LinkageError e) {
logger.error("Unable to load extension {} [class {}]", agentExtension.extensionName(), agentExtension.getClass().getName(), e);
}
}
logger.debug("Installed {} extension(s)", numberOfLoadedExtensions);
ResettableClassFileTransformer resettableClassFileTransformer = agentBuilder.installOn(inst);
ClassFileTransformerHolder.setClassFileTransformer(resettableClassFileTransformer);
if (autoConfiguredSdk != null) {
runAfterAgentListeners(agentListeners, config, autoConfiguredSdk);
}
return resettableClassFileTransformer;
}
use of io.opentelemetry.instrumentation.api.config.Config in project splunk-otel-java by signalfx.
the class JfrSettingsOverridesTest method fallBackToDeprecatedConfig.
@Test
void fallBackToDeprecatedConfig() {
Config config = mock(Config.class);
when(config.getDuration(CONFIG_KEY_DEPRECATED_THREADDUMP_PERIOD, Duration.ZERO)).thenReturn(Duration.ofMillis(999));
JfrSettingsOverrides overrides = new JfrSettingsOverrides(config);
Map<String, String> jfrSettings = Map.of("jdk.ThreadDump#period", "12", "jdk.ThreadDump#enabled", "true");
Map<String, String> result = overrides.apply(jfrSettings);
assertNotSame(result, jfrSettings);
assertEquals("999 ms", result.get("jdk.ThreadDump#period"));
}
use of io.opentelemetry.instrumentation.api.config.Config in project splunk-otel-java by signalfx.
the class JfrSettingsOverridesTest method testOverrides.
@Test
void testOverrides() {
Config config = mock(Config.class);
when(config.getDuration(CONFIG_KEY_CALL_STACK_INTERVAL, Duration.ZERO)).thenReturn(Duration.ofMillis(163));
when(config.getBoolean("splunk.profiler.tlab.enabled", false)).thenReturn(true);
JfrSettingsOverrides overrides = new JfrSettingsOverrides(config);
Map<String, String> jfrSettings = Map.of("jdk.ThreadDump#period", "12", "jdk.ThreadDump#enabled", "true", "jdk.ObjectAllocationInNewTLAB#enabled", "true", "jdk.ObjectAllocationOutsideTLAB#enabled", "true");
Map<String, String> result = overrides.apply(jfrSettings);
assertNotSame(result, jfrSettings);
assertEquals("163 ms", result.get("jdk.ThreadDump#period"));
assertEquals("true", result.get("jdk.ObjectAllocationInNewTLAB#enabled"));
assertEquals("true", result.get("jdk.ObjectAllocationOutsideTLAB#enabled"));
}
Aggregations