diff --git a/instrumentation/resources/library/src/main/java/io/opentelemetry/instrumentation/resources/JarServiceVersionDetector.java b/instrumentation/resources/library/src/main/java/io/opentelemetry/instrumentation/resources/JarServiceVersionDetector.java index e08d84144dce..ec749528dc6f 100644 --- a/instrumentation/resources/library/src/main/java/io/opentelemetry/instrumentation/resources/JarServiceVersionDetector.java +++ b/instrumentation/resources/library/src/main/java/io/opentelemetry/instrumentation/resources/JarServiceVersionDetector.java @@ -60,7 +60,8 @@ public Resource createResource(ConfigProperties config) { @Override public boolean shouldApply(ConfigProperties config, Resource existing) { return !config - .getMap("otel.resource.attributes") - .containsKey(ResourceAttributes.SERVICE_VERSION.getKey()); + .getMap("otel.resource.attributes") + .containsKey(ResourceAttributes.SERVICE_VERSION.getKey()) + && existing.getAttribute(ResourceAttributes.SERVICE_VERSION) == null; } }