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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.solarwinds.opentelemetry.extensions;

import static com.solarwinds.opentelemetry.extensions.SharedNames.COMPONENT_NAME;
import static com.solarwinds.opentelemetry.extensions.SharedNames.SPAN_STACKTRACE_FILTER_CLASS;
import static com.solarwinds.opentelemetry.extensions.config.provider.AutoConfigurationCustomizerProviderImpl.isAgentEnabled;

import java.util.HashMap;
Expand All @@ -33,23 +32,13 @@ public class SolarwindsPropertiesSupplier implements Supplier<Map<String, String
PROPERTIES.put("otel.logs.exporter", "none");
PROPERTIES.put("otel.exporter.otlp.compression", "gzip");

PROPERTIES.put("otel.java.experimental.span-stacktrace.filter", SPAN_STACKTRACE_FILTER_CLASS);
PROPERTIES.put("otel.propagators", String.format("tracecontext,baggage,%s", COMPONENT_NAME));
PROPERTIES.put("otel.semconv-stability.opt-in", "database/dup");

PROPERTIES.put("otel.exporter.otlp.metrics.temporality.preference", "delta");
PROPERTIES.put(
"otel.exporter.otlp.metrics.default.histogram.aggregation",
"base2_exponential_bucket_histogram");
PROPERTIES.put(
"otel.instrumentation.runtime-telemetry.emit-experimental-jfr-metrics", "true");
PROPERTIES.put("otel.resource.providers.azure.enabled", "true");
PROPERTIES.put("otel.resource.providers.aws.enabled", "true");

PROPERTIES.put(
"otel.java.disabled.resource.providers",
"io.opentelemetry.sdk.autoconfigure.ServiceInstanceIdResourceProvider");

} else {
PROPERTIES.put("otel.sdk.disabled", "true");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.opentelemetry.extensions.MetricExporterCustomizer;
import com.solarwinds.opentelemetry.extensions.ResourceCustomizer;
import com.solarwinds.opentelemetry.extensions.SharedPropertiesSupplier;
import com.solarwinds.opentelemetry.extensions.SolarwindsPropertiesSupplier;
import com.solarwinds.opentelemetry.extensions.SolarwindsTracerProviderCustomizer;
import com.solarwinds.opentelemetry.extensions.config.ConfigurationLoader;
Expand Down Expand Up @@ -71,6 +72,7 @@ public void customize(@Nonnull AutoConfigurationCustomizer autoConfiguration) {
}

autoConfiguration
.addPropertiesSupplier(new SharedPropertiesSupplier())
.addPropertiesSupplier(new SolarwindsPropertiesSupplier())
.addTracerProviderCustomizer(new SolarwindsTracerProviderCustomizer())
.addMetricExporterCustomizer(new MetricExporterCustomizer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
package com.solarwinds.opentelemetry.extensions.provider;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.atMostOnce;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.solarwinds.opentelemetry.extensions.SharedPropertiesSupplier;
import com.solarwinds.opentelemetry.extensions.SolarwindsPropertiesSupplier;
import com.solarwinds.opentelemetry.extensions.config.provider.AutoConfigurationCustomizerProviderImpl;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import java.lang.invoke.MethodHandle;
Expand Down Expand Up @@ -79,6 +82,10 @@ void verifyThatAutoConfigurationIsCustomizedWithSwoDefaultPropertiesAndTraceProv
tested.customize(autoConfigurationCustomizerMock);

verify(autoConfigurationCustomizerMock, atMostOnce()).addPropertiesCustomizer(any());
verify(autoConfigurationCustomizerMock)
.addPropertiesSupplier(isA(SharedPropertiesSupplier.class));
verify(autoConfigurationCustomizerMock)
.addPropertiesSupplier(isA(SolarwindsPropertiesSupplier.class));
verify(autoConfigurationCustomizerMock, atMostOnce()).addTracerProviderCustomizer(any());

verify(autoConfigurationCustomizerMock, atMostOnce()).addResourceCustomizer(any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static boolean isAgentEnabled() {
@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
autoConfiguration
.addPropertiesSupplier(new SharedPropertiesSupplier())
.addPropertiesSupplier(new PropertiesSupplier())
.addTracerProviderCustomizer(new TraceProviderCustomizer())
.addResourceCustomizer(new ResourceCustomizer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.solarwinds.opentelemetry.extensions;

import static com.solarwinds.opentelemetry.extensions.SharedNames.COMPONENT_NAME;
import static com.solarwinds.opentelemetry.extensions.SharedNames.SPAN_STACKTRACE_FILTER_CLASS;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -31,13 +30,6 @@ public PropertiesSupplier() {
defaultProperties.put(
"otel.propagators", String.format("tracecontext,baggage,%s,xray", COMPONENT_NAME));
defaultProperties.put("otel.instrumentation.runtime-telemetry.enabled", "false");
defaultProperties.put(
"otel.java.experimental.span-stacktrace.filter", SPAN_STACKTRACE_FILTER_CLASS);
defaultProperties.put("otel.semconv-stability.opt-in", "database/dup");
defaultProperties.put("otel.exporter.otlp.metrics.temporality.preference", "delta");
defaultProperties.put(
"otel.exporter.otlp.metrics.default.histogram.aggregation",
"base2_exponential_bucket_histogram");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.solarwinds.opentelemetry.extensions;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -47,7 +48,9 @@ void ensureExpectedCustomization() {

tested.customize(autoConfigurationCustomizerMock);

verify(autoConfigurationCustomizerMock).addPropertiesSupplier(any());
verify(autoConfigurationCustomizerMock)
.addPropertiesSupplier(isA(SharedPropertiesSupplier.class));
verify(autoConfigurationCustomizerMock).addPropertiesSupplier(isA(PropertiesSupplier.class));
verify(autoConfigurationCustomizerMock).addTracerProviderCustomizer(any());
verify(autoConfigurationCustomizerMock).addResourceCustomizer(any());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* © SolarWinds Worldwide, LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.solarwinds.opentelemetry.extensions;

import static com.solarwinds.opentelemetry.extensions.SharedNames.SPAN_STACKTRACE_FILTER_CLASS;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

public class SharedPropertiesSupplier implements Supplier<Map<String, String>> {
private static final Map<String, String> PROPERTIES;

static {
PROPERTIES = new HashMap<>();
PROPERTIES.put("otel.java.experimental.span-stacktrace.filter", SPAN_STACKTRACE_FILTER_CLASS);
PROPERTIES.put("otel.semconv-stability.opt-in", "database/dup");

PROPERTIES.put("otel.exporter.otlp.metrics.temporality.preference", "delta");
PROPERTIES.put(
"otel.exporter.otlp.metrics.default.histogram.aggregation",
"base2_exponential_bucket_histogram");

PROPERTIES.put(
"otel.java.disabled.resource.providers",
"io.opentelemetry.sdk.autoconfigure.ServiceInstanceIdResourceProvider");
}

@Override
public Map<String, String> get() {
return PROPERTIES;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* © SolarWinds Worldwide, LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.solarwinds.opentelemetry.extensions;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Map;
import org.junit.jupiter.api.Test;

class SharedPropertiesSupplierTest {

private final Map<String, String> properties = new SharedPropertiesSupplier().get();

@Test
void disablesServiceInstanceIdResourceProvider() {
assertEquals(
"io.opentelemetry.sdk.autoconfigure.ServiceInstanceIdResourceProvider",
properties.get("otel.java.disabled.resource.providers"));
}

@Test
void usesSolarwindsSpanStacktraceFilter() {
assertEquals(
SharedNames.SPAN_STACKTRACE_FILTER_CLASS,
properties.get("otel.java.experimental.span-stacktrace.filter"));
}

@Test
void configuresDeltaTemporalityAndExponentialHistograms() {
assertEquals("delta", properties.get("otel.exporter.otlp.metrics.temporality.preference"));
assertEquals(
"base2_exponential_bucket_histogram",
properties.get("otel.exporter.otlp.metrics.default.histogram.aggregation"));
}

@Test
void optsIntoDuplicateDatabaseSemconv() {
assertEquals("database/dup", properties.get("otel.semconv-stability.opt-in"));
}
}
Loading