Search in sources :

Example 11 with Config

use of io.opentelemetry.instrumentation.api.config.Config in project splunk-otel-java by signalfx.

the class RelevantEventsTest method testTlabNotEnabled.

@Test
void testTlabNotEnabled() {
    Config config = mock(Config.class);
    when(config.getBoolean(Configuration.CONFIG_KEY_TLAB_ENABLED, Configuration.DEFAULT_MEMORY_ENABLED)).thenReturn(false);
    RelevantEvents relevantEvents = RelevantEvents.create(config);
    assertTrue(relevantEvents.isRelevant(threadDump));
    assertFalse(relevantEvents.isRelevant(tlab));
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Example 12 with Config

use of io.opentelemetry.instrumentation.api.config.Config in project splunk-otel-java by signalfx.

the class ConfigurationLoggerTest method testLog.

@Test
void testLog() {
    Config config = mock(Config.class);
    when(config.getBoolean(CONFIG_KEY_ENABLE_PROFILER, false)).thenReturn(true);
    when(config.getString(CONFIG_KEY_PROFILER_DIRECTORY)).thenReturn("somedir");
    when(config.getString(CONFIG_KEY_RECORDING_DURATION)).thenReturn("33m");
    when(config.getBoolean(CONFIG_KEY_KEEP_FILES, false)).thenReturn(true);
    when(config.getString(CONFIG_KEY_OTEL_OTLP_URL, null)).thenReturn("http://otel.example.com");
    when(config.getString(CONFIG_KEY_INGEST_URL, "http://otel.example.com")).thenReturn("http://example.com");
    when(config.getBoolean(CONFIG_KEY_MEMORY_ENABLED, DEFAULT_MEMORY_ENABLED)).thenReturn(false);
    when(config.getBoolean(CONFIG_KEY_TLAB_ENABLED, false)).thenReturn(true);
    when(config.getDuration(CONFIG_KEY_CALL_STACK_INTERVAL, DEFAULT_CALL_STACK_INTERVAL)).thenReturn(Duration.ofSeconds(21));
    when(config.getBoolean(CONFIG_KEY_INCLUDE_INTERNAL_STACKS, DEFAULT_INCLUDE_INTERNAL_STACKS)).thenReturn(true);
    when(config.getBoolean(CONFIG_KEY_TRACING_STACKS_ONLY, DEFAULT_TRACING_STACKS_ONLY)).thenReturn(true);
    when(config.getDuration(CONFIG_KEY_DEPRECATED_THREADDUMP_PERIOD, null)).thenReturn(Duration.ofMillis(500));
    ConfigurationLogger configurationLogger = new ConfigurationLogger();
    configurationLogger.log(config);
    log.assertContains("-----------------------");
    log.assertContains("Profiler configuration:");
    log.assertContains("                splunk.profiler.enabled : true");
    log.assertContains("              splunk.profiler.directory : somedir");
    log.assertContains("     splunk.profiler.recording.duration : 33m");
    log.assertContains("             splunk.profiler.keep-files : true");
    log.assertContains("          splunk.profiler.logs-endpoint : http://example.com");
    log.assertContains("            otel.exporter.otlp.endpoint : http://otel.example.com");
    log.assertContains("         splunk.profiler.memory.enabled : false");
    log.assertContains("           splunk.profiler.tlab.enabled : true");
    log.assertContains("    splunk.profiler.call.stack.interval : PT21S");
    log.assertContains("splunk.profiler.include.internal.stacks : true");
    log.assertContains("    splunk.profiler.tracing.stacks.only : true");
    log.assertContains("      splunk.profiler.period.threaddump : PT0.5S");
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Example 13 with Config

use of io.opentelemetry.instrumentation.api.config.Config in project splunk-otel-java by signalfx.

the class TestMicrometerInstaller method beforeAgent.

@Override
public void beforeAgent(Config config, AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) {
    Tags globalMetricsTags = config.getMap("splunk.testing.metrics.global-tags", emptyMap()).entrySet().stream().map(e -> Tag.of(e.getKey(), e.getValue())).reduce(Tags.empty(), Tags::and, Tags::concat);
    SimpleMeterRegistry registry = new SimpleMeterRegistry();
    registry.config().meterFilter(MeterFilter.commonTags(globalMetricsTags));
    Metrics.addRegistry(registry);
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Config(io.opentelemetry.instrumentation.api.config.Config) Collections.emptyMap(java.util.Collections.emptyMap) Tag(io.micrometer.core.instrument.Tag) Tags(io.micrometer.core.instrument.Tags) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) AutoConfiguredOpenTelemetrySdk(io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk) AutoService(com.google.auto.service.AutoService) AgentListener(io.opentelemetry.javaagent.extension.AgentListener) Metrics(io.micrometer.core.instrument.Metrics) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Tags(io.micrometer.core.instrument.Tags)

Example 14 with Config

use of io.opentelemetry.instrumentation.api.config.Config in project opentelemetry-java-instrumentation by open-telemetry.

the class UserExcludedClassesConfigurerTest method shouldIgnoreClassesAndPackages.

@Test
void shouldIgnoreClassesAndPackages() {
    // given
    Config config = Config.builder().readProperties(singletonMap(EXCLUDED_CLASSES_CONFIG, "com.example.IgnoredClass,com.example.ignored.*,com.another_ignore")).build();
    // when
    underTest.configure(config, builder);
    // then
    verify(builder).ignoreClass("com.example.IgnoredClass");
    verify(builder).ignoreClass("com.example.ignored.");
    verify(builder).ignoreClass("com.another_ignore");
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Example 15 with Config

use of io.opentelemetry.instrumentation.api.config.Config in project splunk-otel-java by signalfx.

the class ConfigurationTest method getConfigUrl_endpointNotDefined.

@Test
void getConfigUrl_endpointNotDefined() {
    Config config = mock(Config.class);
    when(config.getString(Configuration.CONFIG_KEY_OTEL_OTLP_URL, null)).thenReturn(otelEndpoint);
    when(config.getString(Configuration.CONFIG_KEY_INGEST_URL, otelEndpoint)).thenReturn(otelEndpoint);
    String result = Configuration.getConfigUrl(config);
    assertEquals(result, otelEndpoint);
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Aggregations

Config (io.opentelemetry.instrumentation.api.config.Config)23 Test (org.junit.jupiter.api.Test)19 RecordedEvent (jdk.jfr.consumer.RecordedEvent)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 CONFIG_KEY_MEMORY_SAMPLER_INTERVAL (com.splunk.opentelemetry.profiler.Configuration.CONFIG_KEY_MEMORY_SAMPLER_INTERVAL)2 CONFIG_KEY_TLAB_ENABLED (com.splunk.opentelemetry.profiler.Configuration.CONFIG_KEY_TLAB_ENABLED)2 DEFAULT_MEMORY_ENABLED (com.splunk.opentelemetry.profiler.Configuration.DEFAULT_MEMORY_ENABLED)2 DEFAULT_MEMORY_SAMPLING_INTERVAL (com.splunk.opentelemetry.profiler.Configuration.DEFAULT_MEMORY_SAMPLING_INTERVAL)2 SOURCE_EVENT_NAME (com.splunk.opentelemetry.profiler.ProfilingSemanticAttributes.SOURCE_EVENT_NAME)2 SOURCE_TYPE (com.splunk.opentelemetry.profiler.ProfilingSemanticAttributes.SOURCE_TYPE)2 ALLOCATION_SIZE_KEY (com.splunk.opentelemetry.profiler.TLABProcessor.ALLOCATION_SIZE_KEY)2 SpanContextualizer (com.splunk.opentelemetry.profiler.context.SpanContextualizer)2 SpanLinkage (com.splunk.opentelemetry.profiler.context.SpanLinkage)2 EventPeriods (com.splunk.opentelemetry.profiler.events.EventPeriods)2 StackSerializer (com.splunk.opentelemetry.profiler.util.StackSerializer)2 AttributeKey (io.opentelemetry.api.common.AttributeKey)2 SpanContext (io.opentelemetry.api.trace.SpanContext)2 SpanId (io.opentelemetry.api.trace.SpanId)2 TraceFlags (io.opentelemetry.api.trace.TraceFlags)2 TraceId (io.opentelemetry.api.trace.TraceId)2