Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions custom/src/test/resources/sdk-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ meter_provider:
timeout: 10000
# Configure headers. Entries have higher priority than entries from .headers_list.
headers_list: ${OTEL_EXPORTER_OTLP_HEADERS}
# Configure temporality preference.
temporality_preference: cumulative
# Configure default histogram aggregation.
default_histogram_aggregation: explicit_bucket_histogram

# Configure logger provider.
logger_provider:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public LogSetting convert(DeclarativeConfigProperties declarativeConfigPropertie
loggingSettings.getBoolean("stdout", true),
loggingSettings.getBoolean("stderr", true),
filePath,
fileInfo.getInt("maxSize"),
fileInfo.getInt("maxBackup"));
fileInfo.getInt("max_size"),
fileInfo.getInt("max_backup"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class AbstractSamplerComponentProvider implements ComponentProvi

private static final String TRACING_ENABLED = "tracing_enabled";

private static final String TRIGGER_TRACE_ENABLED = "trigger_trace_enabled";
private static final String TRIGGER_TRACING_ENABLED = "trigger_tracing_enabled";

private static final String TRANSACTION_SETTINGS = "transaction_settings";

Expand Down Expand Up @@ -76,7 +76,7 @@ public Sampler create(DeclarativeConfigProperties declarativeConfigProperties) {
SamplingConfiguration.builder()
.tracingMode(parseTracingMode(declarativeConfigProperties))
.triggerTraceEnabled(
declarativeConfigProperties.getBoolean(TRIGGER_TRACE_ENABLED, true))
declarativeConfigProperties.getBoolean(TRIGGER_TRACING_ENABLED, true))
.internalTransactionSettings(parseTraceConfigs(declarativeConfigProperties));

parseConfig(declarativeConfigProperties, builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
import io.opentelemetry.exporter.otlp.internal.OtlpDeclarativeConfigUtil;
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.metrics.Aggregation;
import io.opentelemetry.sdk.metrics.InstrumentType;
import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector;
import io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import java.net.InetSocketAddress;

Expand Down Expand Up @@ -69,6 +72,9 @@ public MetricExporter create(DeclarativeConfigProperties config) {
() -> builder.setMeterProvider(MeterProvider::noop));

builder.setAggregationTemporalitySelector(AggregationTemporalitySelector.deltaPreferred());
builder.setDefaultAggregationSelector(
DefaultAggregationSelector.getDefault()
.with(InstrumentType.HISTOGRAM, Aggregation.base2ExponentialBucketHistogram()));

ProxyConfig proxyConfig = ProxyHelper.toProxyConfig(config);
if (proxyConfig != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
import com.solarwinds.joboe.logging.Logger;
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
import io.opentelemetry.sdk.autoconfigure.declarativeconfig.DeclarativeConfiguration;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -53,8 +56,32 @@ void testConvert() throws InvalidConfigException {
assertEquals(new LogSetting(Logger.Level.TRACE, true, true, null, 10, 5), logSetting);
}

@Test
void testConvertWithFileSettings() throws InvalidConfigException {
LogSetting logSetting =
tested.convert(
fromYaml(
"logging:\n"
+ " level: debug\n"
+ " stdout: false\n"
+ " stderr: false\n"
+ " file:\n"
+ " location: /tmp/agent.log\n"
+ " max_size: 20\n"
+ " max_backup: 3\n"));

assertEquals(
new LogSetting(Logger.Level.DEBUG, false, false, Paths.get("/tmp/agent.log"), 20, 3),
logSetting);
}

@Test
void configKey() {
assertEquals("logging", tested.configKey());
}

private static DeclarativeConfigProperties fromYaml(String yaml) {
return DeclarativeConfiguration.toConfigProperties(
new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void testCreateWithEmptyConfigUsesDefaults() {

@Test
void testCreateDisablesTriggerTrace() {
tested.create(fromYaml("swo_http:\n trigger_trace_enabled: false\n"));
tested.create(fromYaml("swo_http:\n trigger_tracing_enabled: false\n"));
assertFalse(samplingConfiguration().isTriggerTraceEnabled());
}

Expand Down Expand Up @@ -179,7 +179,7 @@ void testCreateAppliesExtensionsMatcher() {
@MethodSource("invalidConfigs")
void testCreateThrowsForInvalidConfig(String description, String yaml, String expectedMessage) {
tested.create(
fromYaml("swo_http:\n tracing_enabled: false\n trigger_trace_enabled: false\n"));
fromYaml("swo_http:\n tracing_enabled: false\n trigger_tracing_enabled: false\n"));
SamplingConfiguration previous = samplingConfiguration();

RuntimeException exception =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

import com.solarwinds.opentelemetry.extensions.DelegatingMetricExporter;
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
import io.opentelemetry.sdk.metrics.Aggregation;
import io.opentelemetry.sdk.metrics.InstrumentType;
import io.opentelemetry.sdk.metrics.data.AggregationTemporality;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -70,6 +73,36 @@ void testCreateWithDefaults() {
assertEquals(true, arguments.get(1));
}

@Test
void testCreateUsesDeltaTemporalityAndBase2ExponentialHistogram() {
assertDeltaAndBase2(
createAndCaptureArguments("swo_otlp:\n endpoint: https://localhost:4318/v1/metrics\n"));
}

@Test
void testCreateIgnoresConfiguredTemporalityAndHistogramAggregation() {
assertDeltaAndBase2(
createAndCaptureArguments(
"swo_otlp:\n"
+ " endpoint: https://localhost:4318/v1/metrics\n"
+ " temporality_preference: cumulative\n"
+ " default_histogram_aggregation: explicit_bucket_histogram\n"));
}
Comment thread
jerrytfleung marked this conversation as resolved.
Resolved

private static void assertDeltaAndBase2(List<?> arguments) {
MetricExporter delegate = (MetricExporter) arguments.get(0);

assertEquals(
AggregationTemporality.DELTA, delegate.getAggregationTemporality(InstrumentType.COUNTER));

assertEquals(
AggregationTemporality.DELTA, delegate.getAggregationTemporality(InstrumentType.HISTOGRAM));

assertEquals(
Aggregation.base2ExponentialBucketHistogram().toString(),
delegate.getDefaultAggregation(InstrumentType.HISTOGRAM).toString());
}

private List<?> createAndCaptureArguments(String yaml) {
DeclarativeConfigProperties config = exporterConfig(yaml);
List<List<?>> arguments = new ArrayList<>();
Expand Down
6 changes: 1 addition & 5 deletions libs/shared/src/test/resources/sdk-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ tracer_provider:
# Configure sampler.
swo_http:
tracing_enabled: true
trigger_trace_enabled: true
trigger_tracing_enabled: true
transaction_settings:
- regex: ".*/specialties"
tracing: "disabled"
Expand Down Expand Up @@ -105,10 +105,6 @@ meter_provider:
timeout: 10000
# Configure headers. Entries have higher priority than entries from .headers_list.
headers_list: ${OTEL_EXPORTER_OTLP_HEADERS}
# Configure temporality preference.
temporality_preference: cumulative
# Configure default histogram aggregation.
default_histogram_aggregation: explicit_bucket_histogram

# Configure logger provider.
logger_provider:
Expand Down
Loading
Loading