diff --git a/splunk-otel-android/src/main/java/com/splunk/rum/RumInitializer.java b/splunk-otel-android/src/main/java/com/splunk/rum/RumInitializer.java index 670bac4a..b9c575b9 100644 --- a/splunk-otel-android/src/main/java/com/splunk/rum/RumInitializer.java +++ b/splunk-otel-android/src/main/java/com/splunk/rum/RumInitializer.java @@ -22,25 +22,16 @@ import static com.splunk.rum.SplunkRum.COMPONENT_KEY; import static com.splunk.rum.SplunkRum.COMPONENT_UI; import static com.splunk.rum.SplunkRum.RUM_TRACER_NAME; -import static java.util.Objects.requireNonNull; import static io.opentelemetry.android.RumConstants.APP_START_SPAN_NAME; import static io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor.constant; import static io.opentelemetry.semconv.ResourceAttributes.DEPLOYMENT_ENVIRONMENT; +import static java.util.Objects.requireNonNull; import android.app.Application; import android.os.Looper; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; - import com.splunk.rum.internal.GlobalAttributesSupplier; - -import java.time.Duration; -import java.util.Collection; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.logging.Level; - import io.opentelemetry.android.OpenTelemetryRum; import io.opentelemetry.android.OpenTelemetryRumBuilder; import io.opentelemetry.android.RuntimeDetailsExtractor; @@ -67,6 +58,11 @@ import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; import io.opentelemetry.sdk.trace.export.SpanExporter; +import java.time.Duration; +import java.util.Collection; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.logging.Level; import zipkin2.reporter.Sender; import zipkin2.reporter.okhttp3.OkHttpSender; @@ -97,7 +93,8 @@ SplunkRum initialize( initializationEvents.begin(); OtelRumConfig config = new OtelRumConfig(); - GlobalAttributesSupplier globalAttributeSupplier = new GlobalAttributesSupplier(builder.globalAttributes); + GlobalAttributesSupplier globalAttributeSupplier = + new GlobalAttributesSupplier(builder.globalAttributes); config.setGlobalAttributes(globalAttributeSupplier); OpenTelemetryRumBuilder otelRumBuilder = OpenTelemetryRum.builder(application, config); diff --git a/splunk-otel-android/src/main/java/com/splunk/rum/SplunkRum.java b/splunk-otel-android/src/main/java/com/splunk/rum/SplunkRum.java index e90e8f8e..5a9922f7 100644 --- a/splunk-otel-android/src/main/java/com/splunk/rum/SplunkRum.java +++ b/splunk-otel-android/src/main/java/com/splunk/rum/SplunkRum.java @@ -26,9 +26,7 @@ import android.util.Log; import android.webkit.WebView; import androidx.annotation.Nullable; - import com.splunk.rum.internal.GlobalAttributesSupplier; - import io.opentelemetry.android.OpenTelemetryRum; import io.opentelemetry.android.instrumentation.network.CurrentNetworkProvider; import io.opentelemetry.android.instrumentation.startup.AppStartupTimer; diff --git a/splunk-otel-android/src/main/java/com/splunk/rum/internal/GlobalAttributesSupplier.java b/splunk-otel-android/src/main/java/com/splunk/rum/internal/GlobalAttributesSupplier.java index 5087a779..4a4db6e4 100644 --- a/splunk-otel-android/src/main/java/com/splunk/rum/internal/GlobalAttributesSupplier.java +++ b/splunk-otel-android/src/main/java/com/splunk/rum/internal/GlobalAttributesSupplier.java @@ -1,22 +1,37 @@ -package com.splunk.rum.internal; +/* + * Copyright Splunk Inc. + * + * 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. + */ -import java.util.function.Consumer; -import java.util.function.Supplier; +package com.splunk.rum.internal; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; +import java.util.function.Consumer; +import java.util.function.Supplier; /** - * Class to hold and update the set of global attributes that are appended to each - * span. This is used as the supplier to the GlobalAttributesSpanAppender. We need this - * because SplunkRum exposes a topmost update() method, and we can't break that contract, - * and there's no way to get a reference to the GlobalAttributesSpanAppender created by OtelRum. + * Class to hold and update the set of global attributes that are appended to each span. This is + * used as the supplier to the GlobalAttributesSpanAppender. We need this because SplunkRum exposes + * a topmost update() method, and we can't break that contract, and there's no way to get a + * reference to the GlobalAttributesSpanAppender created by OtelRum. * - *

- * When global attributes are more fleshed out in upstream, this will hopefully improve or go away. + *

When global attributes are more fleshed out in upstream, this will hopefully improve or go + * away. * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. */ public class GlobalAttributesSupplier implements Supplier { private Attributes attributes; diff --git a/splunk-otel-android/src/test/java/com/splunk/rum/SplunkRumTest.java b/splunk-otel-android/src/test/java/com/splunk/rum/SplunkRumTest.java index 26707286..b80abf2c 100644 --- a/splunk-otel-android/src/test/java/com/splunk/rum/SplunkRumTest.java +++ b/splunk-otel-android/src/test/java/com/splunk/rum/SplunkRumTest.java @@ -36,10 +36,7 @@ import android.content.Context; import android.location.Location; import android.webkit.WebView; - import com.splunk.rum.internal.GlobalAttributesSupplier; - -import io.opentelemetry.android.GlobalAttributesSpanAppender; import io.opentelemetry.android.OpenTelemetryRum; import io.opentelemetry.android.instrumentation.network.CurrentNetworkProvider; import io.opentelemetry.api.common.Attributes; diff --git a/splunk-otel-android/src/test/java/com/splunk/rum/internal/GlobalAttributesSupplierTest.java b/splunk-otel-android/src/test/java/com/splunk/rum/internal/GlobalAttributesSupplierTest.java index e9bc9251..1ab811df 100644 --- a/splunk-otel-android/src/test/java/com/splunk/rum/internal/GlobalAttributesSupplierTest.java +++ b/splunk-otel-android/src/test/java/com/splunk/rum/internal/GlobalAttributesSupplierTest.java @@ -1,27 +1,41 @@ -package com.splunk.rum.internal; +/* + * Copyright Splunk Inc. + * + * 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. + */ -import static org.junit.jupiter.api.Assertions.*; +package com.splunk.rum.internal; import static io.opentelemetry.api.common.AttributeKey.stringKey; - -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import io.opentelemetry.api.common.Attributes; +import org.junit.jupiter.api.Test; class GlobalAttributesSupplierTest { @Test - void update(){ + void update() { Attributes initial = Attributes.of(stringKey("foo"), "bar", stringKey("bar"), "baz"); GlobalAttributesSupplier testClass = new GlobalAttributesSupplier(initial); - testClass.update(builder -> { - builder.put("jimbo", "hutch"); - builder.remove(stringKey("bar")); - }); + testClass.update( + builder -> { + builder.put("jimbo", "hutch"); + builder.remove(stringKey("bar")); + }); Attributes result = testClass.get(); assertEquals("bar", result.get(stringKey("foo"))); assertEquals("hutch", result.get(stringKey("jimbo"))); assertNull(result.get(stringKey("bar"))); } - -} \ No newline at end of file +}