From d43aa1a913dc9dd887e09820e7f9d490ff6d9582 Mon Sep 17 00:00:00 2001 From: Jason Plumb Date: Mon, 4 Dec 2023 09:59:07 -0800 Subject: [PATCH] spotless --- .../java/com/splunk/rum/RumInitializer.java | 19 ++++------ .../main/java/com/splunk/rum/SplunkRum.java | 2 - .../internal/GlobalAttributesSupplier.java | 37 +++++++++++++------ .../java/com/splunk/rum/SplunkRumTest.java | 3 -- .../GlobalAttributesSupplierTest.java | 36 ++++++++++++------ 5 files changed, 59 insertions(+), 38 deletions(-) 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 670bac4ad..b9c575b9c 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 e90e8f8ea..5a9922f75 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 5087a7793..4a4db6e41 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 267072866..b80abf2c5 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 e9bc9251d..1ab811dfc 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 +}