From ed5affa33eea6237eb4b0795b283d46fe9a99ffb Mon Sep 17 00:00:00 2001 From: jason plumb <75337021+breedx-splk@users.noreply.github.com> Date: Tue, 7 May 2024 07:50:51 -0700 Subject: [PATCH] Addressing a set of semantic conventions deprecations and other warnings (#340) * addressing a set of semantic conventions deprecations and other warnings * spotless * remove dead code --- android-agent/build.gradle.kts | 2 +- .../android/AndroidResource.java | 16 ++++++++-------- .../android/OpenTelemetryRumBuilder.java | 3 +-- .../DiskBufferingConfiguration.java | 11 +++-------- .../diskbuffering/SignalFromDiskExporter.kt | 6 +++--- .../otel.errorprone-conventions.gradle.kts | 2 +- gradle/libs.versions.toml | 1 + .../activity/ActivityTracer.java | 2 +- .../anr/StackTraceFormatter.java | 2 +- instrumentation/crash/build.gradle.kts | 2 +- .../instrumentation/crash/CrashReporter.java | 19 ++++++++++++------- instrumentation/network/build.gradle.kts | 2 +- .../CurrentNetworkAttributesExtractor.java | 12 ++++++------ .../NetworkChangeAttributesExtractor.java | 2 +- .../instrumentation/network/NetworkState.java | 10 +++++----- .../network/PostApi28NetworkDetector.java | 6 +++--- .../network/PostApi28NetworkDetectorTest.java | 2 +- .../volley/library/build.gradle.kts | 2 +- .../VolleyHttpClientAttributesGetter.java | 2 +- .../VolleyResponseAttributesExtractor.java | 7 +++---- 20 files changed, 55 insertions(+), 56 deletions(-) diff --git a/android-agent/build.gradle.kts b/android-agent/build.gradle.kts index 388e7d062..12a0506a7 100644 --- a/android-agent/build.gradle.kts +++ b/android-agent/build.gradle.kts @@ -72,7 +72,7 @@ dependencies { implementation(libs.opentelemetry.sdk) implementation(libs.opentelemetry.exporter.logging) implementation(libs.opentelemetry.instrumentation.api) - implementation(libs.opentelemetry.semconv) + implementation(libs.opentelemetry.semconv.incubating) implementation(libs.opentelemetry.diskBuffering) testImplementation(libs.robolectric) diff --git a/android-agent/src/main/java/io/opentelemetry/android/AndroidResource.java b/android-agent/src/main/java/io/opentelemetry/android/AndroidResource.java index 5a32b976d..c4ee93c79 100644 --- a/android-agent/src/main/java/io/opentelemetry/android/AndroidResource.java +++ b/android-agent/src/main/java/io/opentelemetry/android/AndroidResource.java @@ -6,14 +6,14 @@ package io.opentelemetry.android; import static io.opentelemetry.android.common.RumConstants.RUM_SDK_VERSION; -import static io.opentelemetry.semconv.ResourceAttributes.DEVICE_MANUFACTURER; -import static io.opentelemetry.semconv.ResourceAttributes.DEVICE_MODEL_IDENTIFIER; -import static io.opentelemetry.semconv.ResourceAttributes.DEVICE_MODEL_NAME; -import static io.opentelemetry.semconv.ResourceAttributes.OS_DESCRIPTION; -import static io.opentelemetry.semconv.ResourceAttributes.OS_NAME; -import static io.opentelemetry.semconv.ResourceAttributes.OS_TYPE; -import static io.opentelemetry.semconv.ResourceAttributes.OS_VERSION; -import static io.opentelemetry.semconv.ResourceAttributes.SERVICE_NAME; +import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME; +import static io.opentelemetry.semconv.incubating.DeviceIncubatingAttributes.DEVICE_MANUFACTURER; +import static io.opentelemetry.semconv.incubating.DeviceIncubatingAttributes.DEVICE_MODEL_IDENTIFIER; +import static io.opentelemetry.semconv.incubating.DeviceIncubatingAttributes.DEVICE_MODEL_NAME; +import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_DESCRIPTION; +import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_NAME; +import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_TYPE; +import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_VERSION; import android.app.Application; import android.os.Build; diff --git a/android-agent/src/main/java/io/opentelemetry/android/OpenTelemetryRumBuilder.java b/android-agent/src/main/java/io/opentelemetry/android/OpenTelemetryRumBuilder.java index 951553d79..479f8a38e 100644 --- a/android-agent/src/main/java/io/opentelemetry/android/OpenTelemetryRumBuilder.java +++ b/android-agent/src/main/java/io/opentelemetry/android/OpenTelemetryRumBuilder.java @@ -273,10 +273,9 @@ public OpenTelemetryRumBuilder addPropagatorCustomizer( public OpenTelemetryRumBuilder addSpanExporterCustomizer( Function spanExporterCustomizer) { requireNonNull(spanExporterCustomizer, "spanExporterCustomizer"); - Function existing = spanExporterCustomizer; this.spanExporterCustomizer = exporter -> { - SpanExporter intermediate = existing.apply(exporter); + SpanExporter intermediate = spanExporterCustomizer.apply(exporter); return spanExporterCustomizer.apply(intermediate); }; return this; diff --git a/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java b/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java index ec73e8a9c..fca90557a 100644 --- a/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java +++ b/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java @@ -24,7 +24,7 @@ private DiskBufferingConfiguration(Builder builder) { } public static Builder builder() { - return new Builder(false, DEFAULT_MAX_CACHE_SIZE); + return new Builder(); } public boolean isEnabled() { @@ -44,16 +44,11 @@ public ExportScheduleHandler getExportScheduleHandler() { } public static final class Builder { - private boolean enabled; - private int maxCacheSize; + private boolean enabled = false; + private int maxCacheSize = DEFAULT_MAX_CACHE_SIZE; private ExportScheduleHandler exportScheduleHandler = new DefaultExportScheduleHandler(new DefaultExportScheduler()); - private Builder(boolean enabled, int maxCacheSize) { - this.enabled = enabled; - this.maxCacheSize = maxCacheSize; - } - /** Enables or disables disk buffering. */ public Builder setEnabled(boolean enabled) { this.enabled = enabled; diff --git a/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/SignalFromDiskExporter.kt b/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/SignalFromDiskExporter.kt index e8614f8ec..8b2bb2330 100644 --- a/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/SignalFromDiskExporter.kt +++ b/android-agent/src/main/java/io/opentelemetry/android/features/diskbuffering/SignalFromDiskExporter.kt @@ -24,7 +24,7 @@ class SignalFromDiskExporter private val exportTimeoutInMillis: Long = TimeUnit.SECONDS.toMillis(5), ) { /** - * A batch contains all the signals that arrived in one call to [SpanDiskExporter.export]. So if + * A batch contains all the signals that arrived in one call to [SpanFromDiskExporter.exportStoredBatch]. So if * that function is called 5 times, then there will be 5 batches in disk. This function reads * and exports ONE batch every time is called. * @@ -41,7 +41,7 @@ class SignalFromDiskExporter } /** - * A batch contains all the signals that arrived in one call to [MetricDiskExporter.export]. So if + * A batch contains all the signals that arrived in one call to [MetricFromDiskExporter.exportStoredBatch]. So if * that function is called 5 times, then there will be 5 batches in disk. This function reads * and exports ONE batch every time is called. * @@ -58,7 +58,7 @@ class SignalFromDiskExporter } /** - * A batch contains all the signals that arrived in one call to [LogRecordDiskExporter.export]. So if + * A batch contains all the signals that arrived in one call to [LogRecordFromDiskExporter.exportStoredBatch]. So if * that function is called 5 times, then there will be 5 batches in disk. This function reads * and exports ONE batch every time is called. * diff --git a/buildSrc/src/main/kotlin/otel.errorprone-conventions.gradle.kts b/buildSrc/src/main/kotlin/otel.errorprone-conventions.gradle.kts index 166a86a6d..669532c42 100644 --- a/buildSrc/src/main/kotlin/otel.errorprone-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/otel.errorprone-conventions.gradle.kts @@ -36,7 +36,7 @@ tasks { options.errorprone { if (name.lowercase(Locale.getDefault()).contains("test")) { // just disable all error prone checks for test - isEnabled.set(false); + isEnabled.set(false) isCompilingTestOnlyCode.set(true) } else { if (isAndroidProject) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 56fe510a4..33a612fa8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,6 +23,7 @@ opentelemetry-instrumentation-api = { module = "io.opentelemetry.instrumentation opentelemetry-instrumentation-apiSemconv = { module = "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator" } opentelemetry-instrumentation-okhttp = { module = "io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0", version.ref = "opentelemetry-instrumentation-alpha" } opentelemetry-semconv = { module = "io.opentelemetry.semconv:opentelemetry-semconv", version.ref = "opentelemetry-semconv" } +opentelemetry-semconv-incubating = { module = "io.opentelemetry.semconv:opentelemetry-semconv-incubating", version.ref = "opentelemetry-semconv" } opentelemetry-api = { module = "io.opentelemetry:opentelemetry-api" } opentelemetry-sdk = { module = "io.opentelemetry:opentelemetry-sdk" } opentelemetry-exporter-logging = { module = "io.opentelemetry:opentelemetry-exporter-logging" } diff --git a/instrumentation/activity/src/main/java/io/opentelemetry/android/instrumentation/activity/ActivityTracer.java b/instrumentation/activity/src/main/java/io/opentelemetry/android/instrumentation/activity/ActivityTracer.java index fd4bf93b7..972259cce 100644 --- a/instrumentation/activity/src/main/java/io/opentelemetry/android/instrumentation/activity/ActivityTracer.java +++ b/instrumentation/activity/src/main/java/io/opentelemetry/android/instrumentation/activity/ActivityTracer.java @@ -134,7 +134,7 @@ public ActivityTracer addEvent(String eventName) { return this; } - public static Builder builder(Activity activity) { + static Builder builder(Activity activity) { return new Builder(activity); } diff --git a/instrumentation/anr/src/main/java/io/opentelemetry/android/instrumentation/anr/StackTraceFormatter.java b/instrumentation/anr/src/main/java/io/opentelemetry/android/instrumentation/anr/StackTraceFormatter.java index 37037f8f3..06a5bf974 100644 --- a/instrumentation/anr/src/main/java/io/opentelemetry/android/instrumentation/anr/StackTraceFormatter.java +++ b/instrumentation/anr/src/main/java/io/opentelemetry/android/instrumentation/anr/StackTraceFormatter.java @@ -5,7 +5,7 @@ package io.opentelemetry.android.instrumentation.anr; -import static io.opentelemetry.semconv.SemanticAttributes.EXCEPTION_STACKTRACE; +import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; diff --git a/instrumentation/crash/build.gradle.kts b/instrumentation/crash/build.gradle.kts index 731e6517c..a803d4838 100644 --- a/instrumentation/crash/build.gradle.kts +++ b/instrumentation/crash/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { api(libs.opentelemetry.api) api(project(":instrumentation:common-api")) implementation(libs.androidx.core) - implementation(libs.opentelemetry.semconv) + implementation(libs.opentelemetry.semconv.incubating) implementation(libs.opentelemetry.sdk) implementation(libs.opentelemetry.instrumentation.api) testImplementation(libs.awaitility) diff --git a/instrumentation/crash/src/main/java/io/opentelemetry/android/instrumentation/crash/CrashReporter.java b/instrumentation/crash/src/main/java/io/opentelemetry/android/instrumentation/crash/CrashReporter.java index cff898f31..7d9b29a41 100644 --- a/instrumentation/crash/src/main/java/io/opentelemetry/android/instrumentation/crash/CrashReporter.java +++ b/instrumentation/crash/src/main/java/io/opentelemetry/android/instrumentation/crash/CrashReporter.java @@ -5,6 +5,12 @@ package io.opentelemetry.android.instrumentation.crash; +import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_ESCAPED; +import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_MESSAGE; +import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE; +import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE; +import static io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes.*; + import io.opentelemetry.android.instrumentation.common.InstrumentedApplication; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; @@ -12,7 +18,6 @@ import io.opentelemetry.api.logs.LoggerProvider; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.semconv.SemanticAttributes; import java.io.PrintWriter; import java.io.StringWriter; import java.util.List; @@ -58,12 +63,12 @@ private void emitCrashEvent(Logger crashReporter, CrashDetails crashDetails) { Thread thread = crashDetails.getThread(); AttributesBuilder attributesBuilder = Attributes.builder() - .put(SemanticAttributes.EXCEPTION_ESCAPED, true) - .put(SemanticAttributes.THREAD_ID, thread.getId()) - .put(SemanticAttributes.THREAD_NAME, thread.getName()) - .put(SemanticAttributes.EXCEPTION_MESSAGE, throwable.getMessage()) - .put(SemanticAttributes.EXCEPTION_STACKTRACE, stackTraceToString(throwable)) - .put(SemanticAttributes.EXCEPTION_TYPE, throwable.getClass().getName()); + .put(EXCEPTION_ESCAPED, true) + .put(THREAD_ID, thread.getId()) + .put(THREAD_NAME, thread.getName()) + .put(EXCEPTION_MESSAGE, throwable.getMessage()) + .put(EXCEPTION_STACKTRACE, stackTraceToString(throwable)) + .put(EXCEPTION_TYPE, throwable.getClass().getName()); for (AttributesExtractor extractor : additionalExtractors) { extractor.onStart(attributesBuilder, Context.current(), crashDetails); diff --git a/instrumentation/network/build.gradle.kts b/instrumentation/network/build.gradle.kts index 69f6824b3..599795533 100644 --- a/instrumentation/network/build.gradle.kts +++ b/instrumentation/network/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { api(project(":common")) api(project(":instrumentation:common-api")) implementation(libs.androidx.core) - implementation(libs.opentelemetry.semconv) + implementation(libs.opentelemetry.semconv.incubating) implementation(libs.opentelemetry.sdk) implementation(libs.opentelemetry.instrumentation.api) testImplementation(libs.robolectric) diff --git a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/CurrentNetworkAttributesExtractor.java b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/CurrentNetworkAttributesExtractor.java index 4ee8928ee..0896a6bdb 100644 --- a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/CurrentNetworkAttributesExtractor.java +++ b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/CurrentNetworkAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.android.instrumentation.network; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CARRIER_ICC; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CARRIER_MCC; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CARRIER_MNC; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CARRIER_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CONNECTION_SUBTYPE; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CONNECTION_TYPE; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_ICC; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_MCC; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_MNC; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CARRIER_NAME; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CONNECTION_SUBTYPE; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CONNECTION_TYPE; import androidx.annotation.Nullable; import io.opentelemetry.api.common.AttributeKey; diff --git a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkChangeAttributesExtractor.java b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkChangeAttributesExtractor.java index 1de10575d..c003352ec 100644 --- a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkChangeAttributesExtractor.java +++ b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkChangeAttributesExtractor.java @@ -6,7 +6,7 @@ package io.opentelemetry.android.instrumentation.network; import static io.opentelemetry.api.common.AttributeKey.stringKey; -import static io.opentelemetry.semconv.SemanticAttributes.NETWORK_CONNECTION_TYPE; +import static io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NETWORK_CONNECTION_TYPE; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; diff --git a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkState.java b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkState.java index 703092e83..4cecea28a 100644 --- a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkState.java +++ b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/NetworkState.java @@ -5,13 +5,13 @@ package io.opentelemetry.android.instrumentation.network; -import io.opentelemetry.semconv.SemanticAttributes; +import io.opentelemetry.semconv.incubating.NetworkIncubatingAttributes.NetworkConnectionTypeValues; enum NetworkState { - NO_NETWORK_AVAILABLE(SemanticAttributes.NetworkConnectionTypeValues.UNAVAILABLE), - TRANSPORT_CELLULAR(SemanticAttributes.NetworkConnectionTypeValues.CELL), - TRANSPORT_WIFI(SemanticAttributes.NetworkConnectionTypeValues.WIFI), - TRANSPORT_UNKNOWN(SemanticAttributes.NetworkConnectionTypeValues.UNKNOWN), + NO_NETWORK_AVAILABLE(NetworkConnectionTypeValues.UNAVAILABLE), + TRANSPORT_CELLULAR(NetworkConnectionTypeValues.CELL), + TRANSPORT_WIFI(NetworkConnectionTypeValues.WIFI), + TRANSPORT_UNKNOWN(NetworkConnectionTypeValues.UNKNOWN), // this one doesn't seem to have an otel value at this point. TRANSPORT_VPN("vpn"); diff --git a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetector.java b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetector.java index 7be4f4f74..5f79de692 100644 --- a/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetector.java +++ b/instrumentation/network/src/main/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetector.java @@ -49,7 +49,7 @@ public CurrentNetwork detectCurrentNetwork() { Carrier carrier = carrierFinder.get(); if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { // If the app has the permission, use it to get a subtype. - if (hasPermission(Manifest.permission.READ_PHONE_STATE)) { + if (canReadPhoneState()) { subType = getDataNetworkTypeName(telephonyManager.getDataNetworkType()); } return CurrentNetwork.builder(NetworkState.TRANSPORT_CELLULAR) @@ -66,8 +66,8 @@ public CurrentNetwork detectCurrentNetwork() { } // visible for testing - boolean hasPermission(String permission) { - return ActivityCompat.checkSelfPermission(context, permission) + boolean canReadPhoneState() { + return ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED; } diff --git a/instrumentation/network/src/test/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetectorTest.java b/instrumentation/network/src/test/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetectorTest.java index 6c549b36d..78507458d 100644 --- a/instrumentation/network/src/test/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetectorTest.java +++ b/instrumentation/network/src/test/java/io/opentelemetry/android/instrumentation/network/PostApi28NetworkDetectorTest.java @@ -96,7 +96,7 @@ public void cellular_noTelephonyPermissions() { new PostApi28NetworkDetector( connectivityManager, telephonyManager, carrierFinder, context) { @Override - boolean hasPermission(String permission) { + boolean canReadPhoneState() { return false; } }; diff --git a/instrumentation/volley/library/build.gradle.kts b/instrumentation/volley/library/build.gradle.kts index 374c344be..5f420137b 100644 --- a/instrumentation/volley/library/build.gradle.kts +++ b/instrumentation/volley/library/build.gradle.kts @@ -38,7 +38,7 @@ dependencies { implementation(libs.androidx.appcompat) implementation(libs.androidx.navigation.fragment) implementation(libs.opentelemetry.instrumentation.api) - implementation(libs.opentelemetry.semconv) + implementation(libs.opentelemetry.semconv.incubating) compileOnly(libs.volley) coreLibraryDesugaring(libs.desugarJdkLibs) diff --git a/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyHttpClientAttributesGetter.java b/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyHttpClientAttributesGetter.java index 75a4c3510..a355d2a66 100644 --- a/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyHttpClientAttributesGetter.java +++ b/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyHttpClientAttributesGetter.java @@ -107,7 +107,7 @@ public List getHttpResponseHeader( } static List headersToList(List
headers, String name) { - if (headers.size() == 0) { + if (headers.isEmpty()) { return emptyList(); } diff --git a/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyResponseAttributesExtractor.java b/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyResponseAttributesExtractor.java index e23434e3c..6a8db355e 100644 --- a/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyResponseAttributesExtractor.java +++ b/instrumentation/volley/library/src/main/java/io/opentelemetry/android/instrumentation/volley/VolleyResponseAttributesExtractor.java @@ -5,13 +5,14 @@ package io.opentelemetry.android.instrumentation.volley; +import static io.opentelemetry.semconv.incubating.HttpIncubatingAttributes.*; + import androidx.annotation.Nullable; import com.android.volley.Header; import com.android.volley.toolbox.HttpResponse; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.semconv.SemanticAttributes; class VolleyResponseAttributesExtractor implements AttributesExtractor { @@ -37,9 +38,7 @@ private void onResponse(AttributesBuilder attributes, HttpResponse response) { if (header.getName().equals("Content-Length")) { String contentLength = header.getValue(); if (contentLength != null) { - attributes.put( - SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, - Long.parseLong(contentLength)); + attributes.put(HTTP_RESPONSE_BODY_SIZE, Long.parseLong(contentLength)); } } }