diff --git a/build.gradle b/build.gradle index 5bb0638b..c36575ea 100644 --- a/build.gradle +++ b/build.gradle @@ -135,29 +135,32 @@ subprojects { ext { assertjVersion = '3.22.0' - autoServiceVersion = '1.0.1' - autoValueVersion = '1.10.1' - slf4jVersion = '2.0.7' - googleCloudVersion = '2.14.0' - googleTraceVersion = '2.14.0' - googleCloudBom = '26.11.0' - cloudMonitoringVersion = '3.15.0' - openTelemetryBom = '1.24.0' - openTelemetryVersion = '1.24.0' - openTelemetryInstrumentationVersion = '1.24.0' - openTelemetrySdkExtensionResourceVersion = '1.19.0' + autoServiceVersion = '1.1.1' + autoValueVersion = '1.10.4' + slf4jVersion = '2.0.9' + googleCloudVersion = '2.27.0' + googleTraceVersion = '2.30.0' + googleCloudBom = '26.26.0' + cloudMonitoringVersion = '3.31.0' + openTelemetryBom = '1.31.0' + openTelemetryVersion = '1.31.0' + openTelemetryInstrumentationVersion = '1.31.0' + openTelemetrySemconvVersion = '1.22.0' junitVersion = '4.13' mockitoVersion = '3.5.10' - pubSubVersion = '1.123.7' + pubSubVersion = '1.125.11' testContainersVersion = '1.15.1' wiremockVersion = '2.27.2' springWebVersion = '2.4.5' springOpenFeignVersion = '3.0.0' springOtelVersion = '1.0.0-M8' - cloudEventsCoreVersion = '2.4.0' + cloudEventsCoreVersion = '2.5.0' cloudFunctionsFrameworkApiVersion = '1.0.4' opencensusShimVersion = '1.23.1' + agentLibraries = [ + agent: "io.opentelemetry.javaagent:opentelemetry-javaagent:${openTelemetryInstrumentationVersion}", + ] libraries = [ auto_service_annotations : "com.google.auto.service:auto-service-annotations:${autoServiceVersion}", auto_service : "com.google.auto.service:auto-service:${autoServiceVersion}", @@ -178,20 +181,16 @@ subprojects { opentelemetry_context : "io.opentelemetry:opentelemetry-context:${openTelemetryVersion}", opentelemetry_sdk : "io.opentelemetry:opentelemetry-sdk:${openTelemetryVersion}", opentelemetry_sdk_common : "io.opentelemetry:opentelemetry-sdk-common:${openTelemetryVersion}", - opentelemetry_autoconfigure_spi : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:${openTelemetryVersion}", - opentelemetry_semconv : "io.opentelemetry:opentelemetry-semconv:${openTelemetryVersion}-alpha", + opentelemetry_semconv : "io.opentelemetry.semconv:opentelemetry-semconv:${openTelemetrySemconvVersion}-alpha", opentelemetry_sdk_metrics : "io.opentelemetry:opentelemetry-sdk-metrics:${openTelemetryVersion}", - opentelemetry_sdk_autoconf : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${openTelemetryVersion}-alpha", - opentelemetry_sdk_resources : "io.opentelemetry:opentelemetry-sdk-extension-resources:${openTelemetrySdkExtensionResourceVersion}", + opentelemetry_sdk_autoconf : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:${openTelemetryVersion}", + opentelemetry_autoconfigure_spi : "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:${openTelemetryVersion}", opentelemetry_agent_extension : "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:${openTelemetryInstrumentationVersion}-alpha", opentelemetry_otlp_exporter : "io.opentelemetry:opentelemetry-exporter-otlp:${openTelemetryVersion}", spring_boot_starter_web : "org.springframework.boot:spring-boot-starter-web:${springWebVersion}", spring_cloud_starter_openfeign : "org.springframework.cloud:spring-cloud-starter-openfeign:${springOpenFeignVersion}", spring_cloud_sleuth_otel_autoconf: "org.springframework.cloud:spring-cloud-sleuth-otel-autoconfigure:${springOtelVersion}", ] - agentLibraries = [ - agent: "io.opentelemetry.javaagent:opentelemetry-javaagent:${openTelemetryInstrumentationVersion}", - ] testLibraries = [ assertj : "org.assertj:assertj-core:${assertjVersion}", junit : "junit:junit:${junitVersion}", diff --git a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java index 07e31d1d..8c05cbc5 100644 --- a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java +++ b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java @@ -16,7 +16,7 @@ package com.google.cloud.opentelemetry.detectors; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; /** * A utility class that contains method that facilitate extraction of attributes from environment diff --git a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java index 72da608b..d56ca208 100644 --- a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java +++ b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java @@ -21,7 +21,7 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; import java.util.logging.Logger; /** diff --git a/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java b/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java index a55b2019..84857095 100644 --- a/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java +++ b/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java @@ -24,7 +24,7 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule; import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; import java.util.HashMap; import java.util.Map; import java.util.ServiceLoader; diff --git a/e2e-test-server/build.gradle b/e2e-test-server/build.gradle index 022ee3b7..b66c76dd 100644 --- a/e2e-test-server/build.gradle +++ b/e2e-test-server/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation platform(libraries.opentelemetry_bom) implementation project(':exporter-trace') implementation project(':propagators-gcp') - runtimeOnly project(':detector-resources') + implementation project(':detector-resources') } -tasks.build.dependsOn tasks.shadowJar \ No newline at end of file +tasks.build.dependsOn tasks.shadowJar diff --git a/e2e-test-server/src/main/java/com/google/cloud/opentelemetry/endtoend/ScenarioHandlerManager.java b/e2e-test-server/src/main/java/com/google/cloud/opentelemetry/endtoend/ScenarioHandlerManager.java index b22102e3..69e71413 100644 --- a/e2e-test-server/src/main/java/com/google/cloud/opentelemetry/endtoend/ScenarioHandlerManager.java +++ b/e2e-test-server/src/main/java/com/google/cloud/opentelemetry/endtoend/ScenarioHandlerManager.java @@ -15,6 +15,7 @@ */ package com.google.cloud.opentelemetry.endtoend; +import com.google.cloud.opentelemetry.detectors.GCPResource; import com.google.cloud.opentelemetry.propagators.XCloudTraceContextPropagator; import com.google.cloud.opentelemetry.trace.TraceConfiguration; import com.google.cloud.opentelemetry.trace.TraceExporter; @@ -28,7 +29,8 @@ import io.opentelemetry.context.propagation.TextMapGetter; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.sdk.OpenTelemetrySdk; -import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; +import io.opentelemetry.sdk.autoconfigure.ResourceConfiguration; +import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; @@ -39,6 +41,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.logging.Logger; @@ -65,7 +68,7 @@ private Response health(Request request) { /** Basic trace test. */ private Response basicTrace(Request request) { - LOGGER.info("Running basicTrace test, request: " + request); + LOGGER.info("Running basicTrace test, request: " + request.toString()); return withTemporaryTracer( (tracer) -> { Span span = @@ -74,6 +77,7 @@ private Response basicTrace(Request request) { .setAttribute(Constants.TEST_ID, request.testId()) .startSpan(); try { + LOGGER.info("Sending trace with ID: " + span.getSpanContext().getTraceId()); return Response.ok(Map.of(Constants.TRACE_ID, span.getSpanContext().getTraceId())); } finally { span.end(); @@ -83,16 +87,17 @@ private Response basicTrace(Request request) { /** Test where we include resource detection */ private Response detectResource(Request request) { - LOGGER.info("Running detectResource test, request: " + request); - // TODO - this may fail to just pull the resource. + LOGGER.info("Running detectResource test, request: " + request.toString()); + Resource gcpResource = + new GCPResource() + .createResource( + DefaultConfigProperties.create( + Map.of("otel.traces.exporter", "none", "otel.metrics.exporter", "none"))); Resource resource = - AutoConfiguredOpenTelemetrySdk.builder() - .setResultAsGlobal(false) - .addPropertiesSupplier( - () -> Map.of("otel.traces.exporter", "none", "otel.metrics.exporter", "none")) - .registerShutdownHook(false) - .build() - .getResource(); + Resource.getDefault() + .merge(gcpResource) + .merge(ResourceConfiguration.createEnvironmentResource()); + return withTemporaryOtel( resource, (sdk) -> { @@ -214,7 +219,7 @@ private static OpenTelemetrySdk setupTraceExporter(Resource resource) throws IOE TraceConfiguration configuration = TraceConfiguration.builder() .setDeadline(Duration.ofMillis(30000)) - .setProjectId(Constants.PROJECT_ID != "" ? Constants.PROJECT_ID : null) + .setProjectId(!Objects.equals(Constants.PROJECT_ID, "") ? Constants.PROJECT_ID : null) .build(); SpanExporter traceExporter = TraceExporter.createWithConfiguration(configuration); diff --git a/examples/resource/build.gradle b/examples/resource/build.gradle index 06f3aa0a..7a4449c9 100644 --- a/examples/resource/build.gradle +++ b/examples/resource/build.gradle @@ -25,7 +25,6 @@ description = 'Examples for showing resource detection in various GCP environmen dependencies { implementation project(':detector-resources') implementation(libraries.opentelemetry_sdk_autoconf) - implementation(libraries.opentelemetry_sdk_resources) implementation(libraries.opentelemetry_otlp_exporter) } diff --git a/examples/resource/src/main/java/com/google/cloud/opentelemetry/example/resource/ResourceExample.java b/examples/resource/src/main/java/com/google/cloud/opentelemetry/example/resource/ResourceExample.java index 3db232c4..b465fd19 100644 --- a/examples/resource/src/main/java/com/google/cloud/opentelemetry/example/resource/ResourceExample.java +++ b/examples/resource/src/main/java/com/google/cloud/opentelemetry/example/resource/ResourceExample.java @@ -16,17 +16,13 @@ package com.google.cloud.opentelemetry.example.resource; import com.google.cloud.opentelemetry.detectors.GCPResource; -import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; +import io.opentelemetry.sdk.autoconfigure.ResourceConfiguration; +import io.opentelemetry.sdk.resources.Resource; public class ResourceExample { public static void main(String[] args) { System.out.println("Detecting resource: Autoconfigure"); - io.opentelemetry.sdk.resources.Resource autoResource = - AutoConfiguredOpenTelemetrySdk.builder() - .setResultAsGlobal(false) - .setServiceClassLoader(ResourceExample.class.getClassLoader()) - .build() - .getResource(); + Resource autoResource = ResourceConfiguration.createEnvironmentResource(); System.out.println(autoResource.getAttributes()); System.out.println("Detecting resource: hardcoded"); GCPResource resource = new GCPResource(); diff --git a/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/FakeData.java b/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/FakeData.java index 98b58d76..ff66b27d 100644 --- a/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/FakeData.java +++ b/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/FakeData.java @@ -42,7 +42,7 @@ import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableSummaryPointData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; import java.util.Arrays; import java.util.Collections; import java.util.Date; diff --git a/exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceVersions.java b/exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceVersions.java index 679801d8..c28f2ac9 100644 --- a/exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceVersions.java +++ b/exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceVersions.java @@ -15,9 +15,7 @@ */ package com.google.cloud.opentelemetry.trace; -import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.TELEMETRY_SDK_VERSION; -// import static -// io.opentelemetry.semconv.resource.attributes.ResourceAttributes.TELEMETRY_SDK_VERSION; +import static io.opentelemetry.semconv.ResourceAttributes.TELEMETRY_SDK_VERSION; import io.opentelemetry.sdk.resources.Resource; import java.util.Properties; diff --git a/exporters/trace/src/test/java/com/google/cloud/opentelemetry/trace/TraceTranslatorTest.java b/exporters/trace/src/test/java/com/google/cloud/opentelemetry/trace/TraceTranslatorTest.java index 503ec70a..f88fceff 100644 --- a/exporters/trace/src/test/java/com/google/cloud/opentelemetry/trace/TraceTranslatorTest.java +++ b/exporters/trace/src/test/java/com/google/cloud/opentelemetry/trace/TraceTranslatorTest.java @@ -35,7 +35,7 @@ import io.opentelemetry.sdk.testing.trace.TestSpanData; import io.opentelemetry.sdk.trace.data.EventData; import io.opentelemetry.sdk.trace.data.StatusData; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; diff --git a/propagators/gcp/src/test/java/com/google/cloud/opentelemetry/propagators/AutoConfigureTest.java b/propagators/gcp/src/test/java/com/google/cloud/opentelemetry/propagators/AutoConfigureTest.java index 425c78c2..a82bdfa8 100644 --- a/propagators/gcp/src/test/java/com/google/cloud/opentelemetry/propagators/AutoConfigureTest.java +++ b/propagators/gcp/src/test/java/com/google/cloud/opentelemetry/propagators/AutoConfigureTest.java @@ -61,8 +61,7 @@ public void findsWithAutoConfigure() { private static ContextPropagators findsWithAutoConfigure(String propagator) { AutoConfiguredOpenTelemetrySdk sdk = AutoConfiguredOpenTelemetrySdk.builder() - .setResultAsGlobal(false) - .registerShutdownHook(false) + .disableShutdownHook() .addPropertiesSupplier( () -> Map.of( @@ -71,6 +70,8 @@ private static ContextPropagators findsWithAutoConfigure(String propagator) { "otel.traces.exporter", "none", "otel.metrics.exporter", + "none", + "otel.logs.exporter", "none")) .build(); return sdk.getOpenTelemetrySdk().getPropagators(); diff --git a/shared/resourcemapping/src/main/java/com/google/cloud/opentelemetry/resource/ResourceTranslator.java b/shared/resourcemapping/src/main/java/com/google/cloud/opentelemetry/resource/ResourceTranslator.java index 0501c9df..f3bb15b3 100644 --- a/shared/resourcemapping/src/main/java/com/google/cloud/opentelemetry/resource/ResourceTranslator.java +++ b/shared/resourcemapping/src/main/java/com/google/cloud/opentelemetry/resource/ResourceTranslator.java @@ -17,7 +17,7 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; import java.util.Arrays; import java.util.List; import java.util.Optional; diff --git a/shared/resourcemapping/src/test/java/com/google/cloud/opentelemetry/resource/ResourceTranslatorTest.java b/shared/resourcemapping/src/test/java/com/google/cloud/opentelemetry/resource/ResourceTranslatorTest.java index 82881df7..63bd3265 100644 --- a/shared/resourcemapping/src/test/java/com/google/cloud/opentelemetry/resource/ResourceTranslatorTest.java +++ b/shared/resourcemapping/src/test/java/com/google/cloud/opentelemetry/resource/ResourceTranslatorTest.java @@ -21,7 +21,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ResourceAttributes; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream;