From ee9a58e0eb705f583422fda45e0e8a0e9dae2e48 Mon Sep 17 00:00:00 2001 From: jason plumb <75337021+breedx-splk@users.noreply.github.com> Date: Tue, 6 Aug 2024 09:20:08 -0700 Subject: [PATCH] Disable upstream default exporter (for now) (#894) * prevent upstream default exporter from being configured (for now). * spotless --- .../java/com/splunk/rum/RumInitializer.java | 4 ++ .../splunk/rum/internal/NoOpSpanExporter.java | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 splunk-otel-android/src/main/java/com/splunk/rum/internal/NoOpSpanExporter.java 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 46a734c1..3e293733 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 @@ -32,6 +32,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.splunk.rum.internal.GlobalAttributesSupplier; +import com.splunk.rum.internal.NoOpSpanExporter; import com.splunk.rum.internal.UInt32QuadXorTraceIdRatioSampler; import io.opentelemetry.android.OpenTelemetryRum; import io.opentelemetry.android.OpenTelemetryRumBuilder; @@ -125,6 +126,9 @@ SplunkRum initialize(Looper mainLooper) { return tracerProviderBuilder.addSpanProcessor(batchSpanProcessor); }); + // Inhibit the upstream exporter because we add our own BatchSpanProcessor + otelRumBuilder.addSpanExporterCustomizer(x -> new NoOpSpanExporter()); + // Set span limits otelRumBuilder.addTracerProviderCustomizer( (tracerProviderBuilder, app) -> diff --git a/splunk-otel-android/src/main/java/com/splunk/rum/internal/NoOpSpanExporter.java b/splunk-otel-android/src/main/java/com/splunk/rum/internal/NoOpSpanExporter.java new file mode 100644 index 00000000..b3ead6c3 --- /dev/null +++ b/splunk-otel-android/src/main/java/com/splunk/rum/internal/NoOpSpanExporter.java @@ -0,0 +1,43 @@ +/* + * 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. + */ + +package com.splunk.rum.internal; + +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.trace.data.SpanData; +import io.opentelemetry.sdk.trace.export.SpanExporter; +import java.util.Collection; + +/* + *
This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public final class NoOpSpanExporter implements SpanExporter {
+ @Override
+ public CompletableResultCode export(Collection