diff --git a/.gitignore b/.gitignore index 1b8663cb..e367f871 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .gradle/ .DS_Store .idea/ +buildSrc/.kotlin/ diff --git a/build.gradle.kts b/build.gradle.kts index 108c9b88..b0026e93 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins{ id("io.github.gradle-nexus.publish-plugin") version "2.0.0" } -val swoAgentVersion = "3.2.0" +val swoAgentVersion = "3.2.1" extra["swoAgentVersion"] = swoAgentVersion group = "com.solarwinds" version = if (System.getenv("SNAPSHOT_BUILD").toBoolean()) "$swoAgentVersion-SNAPSHOT" else swoAgentVersion diff --git a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/HostIdResourceProvider.java b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/HostIdResourceProvider.java index a3832ab1..be0bd3d4 100644 --- a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/HostIdResourceProvider.java +++ b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/HostIdResourceProvider.java @@ -29,4 +29,9 @@ public class HostIdResourceProvider implements ResourceProvider { public Resource createResource(ConfigProperties configProperties) { return Resource.create(HostIdResourceUtil.createAttribute()); } + + @Override + public int order() { + return Integer.MIN_VALUE; + } } diff --git a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsPropertiesSupplier.java b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsPropertiesSupplier.java index b204d197..602aac24 100644 --- a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsPropertiesSupplier.java +++ b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsPropertiesSupplier.java @@ -43,6 +43,8 @@ public class SolarwindsPropertiesSupplier implements Supplier(); } - List newDetectors = new ArrayList<>(detectors); + // Ordering matters: SWO detectors are added first, then upstream detectors (e.g. aws/azure) + // are appended so they run last. With last-writer-wins merge semantics this lets upstream + // cloud attributes override our host-id attributes. Do not reorder without accounting for + // which detector's attributes should survive the merge. + List newDetectors = new ArrayList<>(); newDetectors.add( new ExperimentalResourceDetectorModel() .withAdditionalProperty( @@ -79,6 +83,8 @@ private void addResourceDetector(ResourceModel resourceModel) { .withAdditionalProperty( HostIdResourceComponentProvider.COMPONENT_NAME, new ExperimentalResourceDetectorPropertyModel())); + + newDetectors.addAll(detectors); detectionDevelopment.withDetectors(newDetectors); } diff --git a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/ResourceComponentProvider.java b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/ResourceComponentProvider.java index 9b492db9..6fbbc07a 100644 --- a/custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/ResourceComponentProvider.java +++ b/custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/ResourceComponentProvider.java @@ -33,7 +33,11 @@ public class ResourceComponentProvider implements ComponentProvider { public static final String COMPONENT_NAME = "swo/resource"; - @Getter @Setter private static Resource resource = null; + // Accumulated statically: create() merges into this field in place, and + // HostIdResourceComponentProvider reads it via getResource().merge(...). Assumes create() is + // invoked once; merging identical attributes is idempotent, but any new writer of this field + // must be aware the result is order-dependent. + @Getter @Setter private static Resource resource = Resource.getDefault(); @Override public Class getType() { @@ -50,7 +54,7 @@ public Resource create(DeclarativeConfigProperties declarativeConfigProperties) Attributes resourceAttributes = Attributes.of(moduleKey, "apm", versionKey, BuildConfig.SOLARWINDS_AGENT_VERSION); - resource = Resource.create(resourceAttributes); + resource = resource.merge(Resource.create(resourceAttributes)); return resource; } } diff --git a/custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtilTest.java b/custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtilTest.java index 7d2c9fc7..0d6661bd 100644 --- a/custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtilTest.java +++ b/custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtilTest.java @@ -18,19 +18,16 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.semconv.incubating.HostIncubatingAttributes; -import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes; +import java.util.List; import org.junit.jupiter.api.Test; class HostIdResourceUtilTest { @Test void testCreateAttributes() { Attributes attribute = HostIdResourceUtil.createAttribute(); - Long pid = attribute.get(ProcessIncubatingAttributes.PROCESS_PID); - String hostname = attribute.get(HostIncubatingAttributes.HOST_NAME); - - assertNotNull(pid); - assertNotNull(hostname); + List macAddresses = attribute.get(AttributeKey.stringArrayKey("mac.addresses")); + assertNotNull(macAddresses); } } diff --git a/libs/shared/build.gradle.kts b/libs/shared/build.gradle.kts index cb8126c6..6359f8c9 100644 --- a/libs/shared/build.gradle.kts +++ b/libs/shared/build.gradle.kts @@ -45,6 +45,8 @@ dependencies { implementation("io.opentelemetry.contrib:opentelemetry-cel-sampler") { exclude(module = "opentelemetry-sdk", group = "io.opentelemetry") // the agent includes this exclude(group = "com.google.code.findbugs", module = "annotations") + exclude(group = "com.google.guava", module = "guava") + exclude(group = "com.google.protobuf") } implementation("org.json:json")