Search in sources :

Example 16 with Config

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

the class ConfigurationTest method getConfigUrlNull.

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

Example 17 with Config

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

the class ConfigurationTest method getConfigUrl_endpointDefined.

@Test
void getConfigUrl_endpointDefined() {
    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(logsEndpoint);
    String result = Configuration.getConfigUrl(config);
    assertEquals(result, logsEndpoint);
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Example 18 with Config

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

the class ConfigurationTest method getTLABEnabled_inheritedFalse.

@Test
void getTLABEnabled_inheritedFalse() {
    Config config = mock(Config.class);
    when(config.getBoolean(Configuration.CONFIG_KEY_MEMORY_ENABLED, Configuration.DEFAULT_MEMORY_ENABLED)).thenReturn(false);
    when(config.getBoolean(Configuration.CONFIG_KEY_TLAB_ENABLED, false)).thenReturn(false);
    boolean result = Configuration.getTLABEnabled(config);
    assertFalse(result);
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Example 19 with Config

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

the class ConfigurationLoggerTest method testLogInheritDefaultValues.

@Test
void testLogInheritDefaultValues() {
    Config config = mock(Config.class);
    String inheritedUrl = "http://otel.example.com";
    when(config.getString(CONFIG_KEY_OTEL_OTLP_URL, null)).thenReturn(inheritedUrl);
    when(config.getString(CONFIG_KEY_INGEST_URL, inheritedUrl)).thenReturn(inheritedUrl);
    when(config.getBoolean(CONFIG_KEY_MEMORY_ENABLED, DEFAULT_MEMORY_ENABLED)).thenReturn(true);
    when(config.getBoolean(CONFIG_KEY_TLAB_ENABLED, true)).thenReturn(false);
    ConfigurationLogger configurationLogger = new ConfigurationLogger();
    configurationLogger.log(config);
    log.assertContains("          splunk.profiler.logs-endpoint : http://otel.example.com");
    log.assertContains("            otel.exporter.otlp.endpoint : http://otel.example.com");
    log.assertContains("         splunk.profiler.memory.enabled : true");
    log.assertContains("           splunk.profiler.tlab.enabled : false");
}
Also used : Config(io.opentelemetry.instrumentation.api.config.Config) Test(org.junit.jupiter.api.Test)

Example 20 with Config

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

the class TLABProcessorTest method testProfilingDisabled.

@Test
void testProfilingDisabled() {
    RecordedEvent event = mock(RecordedEvent.class, new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            throw new IllegalStateException("RecordedEvent methods should not be called when TLAB profiling is not enabled");
        }
    });
    Config config = mock(Config.class);
    when(config.getBoolean(CONFIG_KEY_TLAB_ENABLED, DEFAULT_MEMORY_ENABLED)).thenReturn(false);
    TLABProcessor processor = TLABProcessor.builder(config).build();
    processor.accept(event);
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) Config(io.opentelemetry.instrumentation.api.config.Config) RecordedEvent(jdk.jfr.consumer.RecordedEvent) 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