Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholder for 2.x work #802

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
167ca11
placeholder for 2.x work
breedx-splk Apr 10, 2024
2dd5b25
start updating semconv
breedx-splk Apr 10, 2024
f6beb25
update semconv
breedx-splk Apr 10, 2024
7940857
update semconv
breedx-splk Apr 10, 2024
2f01dec
fix test
breedx-splk Apr 10, 2024
548579a
rebase and update
breedx-splk Apr 12, 2024
1f4fc8f
update to 0.7.0-alpha-snapshot and get lots of breakage
breedx-splk Aug 12, 2024
e104981
fix up semconv
breedx-splk Aug 12, 2024
f2dbb70
fix up constants
breedx-splk Aug 12, 2024
3060aa5
fix import
breedx-splk Aug 12, 2024
3cf7ad9
more breakage and todos
breedx-splk Aug 13, 2024
c7062aa
work in progress around 2.x
breedx-splk Aug 27, 2024
cc39d35
work in progress
breedx-splk Sep 4, 2024
527cb83
fix debug span logging
breedx-splk Sep 4, 2024
dd44f66
work in progress -- enable disk buffering
breedx-splk Sep 9, 2024
6849305
remove unnecessary customizer
breedx-splk Sep 13, 2024
f5a362e
cleanup
breedx-splk Sep 13, 2024
81667b6
add todo
breedx-splk Sep 18, 2024
9c1d7a1
format and fix after rebase
breedx-splk Oct 17, 2024
64e5824
remove duplication
breedx-splk Oct 17, 2024
12410e7
set up disk buffering
breedx-splk Oct 17, 2024
d08085d
spotless
breedx-splk Oct 17, 2024
6195d04
remove dead zipkin classes
breedx-splk Oct 17, 2024
786144b
remove unused
breedx-splk Oct 23, 2024
cacee23
remove unused
breedx-splk Oct 23, 2024
0a67218
update dependency versions, remove zipkin dep, fix extractor
breedx-splk Oct 23, 2024
1c7073f
use semconv for old session ids
breedx-splk Oct 23, 2024
8e2d295
fix tests
breedx-splk Oct 23, 2024
3bd1cf8
spotless
breedx-splk Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"matchPackageNames": [
"io.opentelemetry:opentelemetry-api-incubator",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator",
"io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0"
],
// Renovate's default behavior is only to update from unstable -> unstable if it's for the
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true

# generate the BuildConfig class that contains the app version
version=1.8.0
version=2.0.0-alpha
group=com.splunk
28 changes: 15 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[versions]
opentelemetry-core = "1.42.1"
opentelemetry-core-alpha = "1.42.1-alpha"
opentelemetry-inst = "1.33.6"
opentelemetry-inst-alpha = "1.33.6-alpha"
opentelemetry-android = "0.4.0-alpha"
opentelemetry-inst = "2.9.0"
opentelemetry-inst-alpha = "2.9.0-alpha"
opentelemetry-android = "0.8.0-alpha"
opentelemetry-semconv = "1.26.0-alpha"
mockito = "5.14.2"
junit = "5.11.3"
spotless = "6.25.0"
Expand All @@ -15,18 +14,21 @@ navigationCompose = "2.7.7"

[libraries]
opentelemetry-instrumentation-bom = { module = "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom", version.ref = "opentelemetry-inst" }
opentelemetry-bom = { module = "io.opentelemetry:opentelemetry-bom", version.ref = "opentelemetry-core" }
opentelemetry-bom = { module = "io.opentelemetry:opentelemetry-bom" }
opentelemetry-sdk = { module = "io.opentelemetry:opentelemetry-sdk" }
opentelemetry-api = { module = "io.opentelemetry:opentelemetry-api" }
opentelemetry-api-incubator = { module = "io.opentelemetry:opentelemetry-api-incubator", version.ref = "opentelemetry-core-alpha" }
opentelemetry-android = { module = "io.opentelemetry.android:instrumentation", version.ref = "opentelemetry-android" }
opentelemetry-api-incubator = { module = "io.opentelemetry:opentelemetry-api-incubator" }
opentelemetry-api-events = { module = "io.opentelemetry:opentelemetry-api-events" }
opentelemetry-android-agent = { module = "io.opentelemetry.android:android-agent", version.ref = "opentelemetry-android" }
opentelemetry-android-instrumentation-commonapi = { module = "io.opentelemetry.android:instrumentation-common-api", version.ref = "opentelemetry-android" }
opentelemetry-instrumenter-api = { module = "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api", version.ref = "opentelemetry-inst" }
opentelemetry-instrumenter-api-semconv = { module = "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv", version.ref = "opentelemetry-inst-alpha" }
opentelemetry-instrumenter-api-incubator = { module = "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator", version.ref = "opentelemetry-inst-alpha" }
opentelemetry-instrumentation-okhttp = { module = "io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0", version.ref = "opentelemetry-inst-alpha" }
opentelemetry-exporter-zipkin = { module = "io.opentelemetry:opentelemetry-exporter-zipkin", version.ref = "opentelemetry-core" }
opentelemetry-exporter-otlp = { module = "io.opentelemetry:opentelemetry-exporter-otlp", version.ref = "opentelemetry-core" }
opentelemetry-exporter-logging = { module = "io.opentelemetry:opentelemetry-exporter-logging", version.ref = "opentelemetry-core" }
opentelemetry-sdk-testing = { module = "io.opentelemetry:opentelemetry-sdk-testing", version.ref = "opentelemetry-core" }
opentelemetry-exporter-otlp = { module = "io.opentelemetry:opentelemetry-exporter-otlp" }
opentelemetry-exporter-logging = { module = "io.opentelemetry:opentelemetry-exporter-logging" }
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-sdk-testing = { module = "io.opentelemetry:opentelemetry-sdk-testing" }

zipkin-sender-okhttp = "io.zipkin.reporter2:zipkin-sender-okhttp3:3.4.2"

Expand Down
6 changes: 5 additions & 1 deletion sample-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ composeCompiler {
enableStrongSkippingMode = true
}

repositories {
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
}

dependencies {
api(platform(libs.opentelemetry.instrumentation.bom))

Expand All @@ -95,7 +99,7 @@ dependencies {
implementation(libs.android.volley)
implementation(libs.androidx.work)
implementation(libs.opentelemetry.sdk)
implementation(libs.opentelemetry.api.incubator)
implementation(libs.opentelemetry.instrumenter.api.incubator)
testImplementation(libs.bundles.junit)
testRuntimeOnly(libs.junit.platform.launcher)
androidTestImplementation(libs.androidx.test.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class DemoWorker extends Worker {

private Context context;
private final Context context;
public static final String TAG = "SplunkRum";

public DemoWorker(@NonNull Context context, @NonNull WorkerParameters params) {
Expand All @@ -39,7 +39,7 @@ public DemoWorker(@NonNull Context context, @NonNull WorkerParameters params) {
@Override
public Result doWork() {
try {
SplunkRum.getInstance().addRumEvent("DemoWorker is doing work", Attributes.empty());
SplunkRum.getInstance().emitEvent("DemoWorker is doing work", Attributes.empty());
Log.d(TAG, "DemoWorker Starting background Service");
startBackgroundService();
return Result.success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
v -> {
// Without being in a workflow, this will still show up in the UI but wil not be
// grouped under the "Custom Events" tab.
splunkRum.addRumEvent(
splunkRum.emitEvent(
"kustom",
Attributes.of(longKey("counted"), customCount.incrementAndGet()));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
R.string.cancel,
(dialog, id) ->
SplunkRum.getInstance()
.addRumEvent("User Rejected Help", HELPER_ATTRIBUTES));
.emitEvent("User Rejected Help", HELPER_ATTRIBUTES));
return builder.create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import androidx.work.WorkManager;
import com.splunk.android.sample.databinding.ActivityMainBinding;
import com.splunk.rum.SplunkRum;
import io.opentelemetry.android.instrumentation.RumScreenName;
import io.opentelemetry.android.instrumentation.annotations.RumScreenName;
import io.opentelemetry.api.common.Attributes;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@
import androidx.navigation.fragment.NavHostFragment;
import com.splunk.android.sample.databinding.FragmentSecondBinding;
import com.splunk.rum.SplunkRum;
import io.opentelemetry.android.instrumentation.RumScreenName;
import io.opentelemetry.android.instrumentation.annotations.RumScreenName;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.incubator.events.EventLogger;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Scope;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider;
import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -102,8 +99,8 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
binding.buttonToWebview.setOnClickListener(
v -> {
SplunkRum.getInstance()
.addRumEvent("this span will be ignored", Attributes.empty());
emitEvent(SplunkRum.getInstance(), "SecondFragment", "toWebViewClick");
.emitEvent("this span will be ignored", Attributes.empty());
emitEvent(SplunkRum.getInstance(), "SecondFragment.toWebViewClick");

NavHostFragment.findNavController(SecondFragment.this)
.navigate(R.id.action_SecondFragment_to_webViewFragment);
Expand Down Expand Up @@ -219,11 +216,7 @@ private void createSpamSpan() {
updateLabel();
}

public static void emitEvent(SplunkRum splunkRum, String eventDomain, String eventName) {
SdkEventLoggerProvider eventEmitterProvider =
SdkEventLoggerProvider.create(
((OpenTelemetrySdk) splunkRum.getOpenTelemetry()).getSdkLoggerProvider());
EventLogger eventLogger = eventEmitterProvider.eventLoggerBuilder("test").build();
eventLogger.builder(eventName).emit();
public static void emitEvent(SplunkRum splunkRum, String eventName) {
splunkRum.emitEvent(eventName, Attributes.empty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public WebAppInterface(Context context) {

@JavascriptInterface
public void showToast(String toast) {
SplunkRum.getInstance().addRumEvent("WebViewButtonClicked", Attributes.empty());
SplunkRum.getInstance().emitEvent("WebViewButtonClicked", Attributes.empty());
Toast.makeText(context, toast, Toast.LENGTH_LONG).show();
}

Expand Down
3 changes: 2 additions & 1 deletion splunk-otel-android-volley/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ dependencies {
api(platform(libs.opentelemetry.bom))
compileOnly(libs.opentelemetry.api)
implementation(libs.opentelemetry.instrumenter.api)
implementation(libs.opentelemetry.instrumenter.api.semconv)
implementation(libs.opentelemetry.instrumenter.api.incubator)
implementation(libs.opentelemetry.semconv.incubating)
compileOnly(libs.android.volley)
implementation(libs.androidx.core)
testImplementation(libs.mockwebserver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;

/**
* This class is responsible for extracting the Content-Length header and assigning the value to an
Expand Down Expand Up @@ -52,7 +52,8 @@ private void onResponse(AttributesBuilder attributes, HttpResponse response) {
String contentLength = getHeader(response, "Content-Length");
if (contentLength != null) {
attributes.put(
SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, Long.parseLong(contentLength));
HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE,
Long.parseLong(contentLength));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.android.volley.Header;
import com.android.volley.Request;
import com.android.volley.toolbox.HttpResponse;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.splunk.rum;

import static com.splunk.rum.StandardAttributes.EXCEPTION_EVENT_NAME;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

Expand All @@ -25,7 +26,7 @@
import com.android.volley.toolbox.StringRequest;
import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ExceptionAttributes;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.After;
Expand Down Expand Up @@ -75,20 +76,20 @@ public void spanDecoration_error() {
assertThat(span)
.hasEventsSatisfyingExactly(
e ->
e.hasName(SemanticAttributes.EXCEPTION_EVENT_NAME)
e.hasName(EXCEPTION_EVENT_NAME)
.hasAttributesSatisfying(
a ->
assertThat(a)
.containsEntry(
SemanticAttributes
ExceptionAttributes
.EXCEPTION_TYPE,
"java.lang.RuntimeException")
.containsEntry(
SemanticAttributes
ExceptionAttributes
.EXCEPTION_MESSAGE,
"Something went wrong")
.containsKey(
SemanticAttributes
ExceptionAttributes
.EXCEPTION_STACKTRACE)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

package com.splunk.rum;

import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_BODY_SIZE;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE;
import static io.opentelemetry.semconv.incubating.HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Fail.fail;
Expand All @@ -36,7 +37,9 @@
import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.URL;
Expand Down Expand Up @@ -172,7 +175,7 @@ public void connectionError() throws IOException {
.allSatisfy(
e ->
assertThat(e.getName())
.isEqualTo(SemanticAttributes.EXCEPTION_EVENT_NAME));
.isEqualTo(StandardAttributes.EXCEPTION_EVENT_NAME));

verifyAttributes(span, url, null, null);
}
Expand Down Expand Up @@ -260,13 +263,11 @@ private void verifyAttributes(SpanData span, URL url, Long status, String respon

Attributes spanAttributes = span.getAttributes();

// We continue using deprecated semconv for now. When 2.0.0 hits we will need to update
// these.
assertThat(spanAttributes.get(SemanticAttributes.HTTP_STATUS_CODE)).isEqualTo(status);
assertThat(spanAttributes.get(SemanticAttributes.NET_PEER_PORT)).isEqualTo(url.getPort());
assertThat(spanAttributes.get(SemanticAttributes.NET_PEER_NAME)).isEqualTo(url.getHost());
assertThat(spanAttributes.get(SemanticAttributes.HTTP_URL)).isEqualTo(url.toString());
assertThat(spanAttributes.get(SemanticAttributes.HTTP_METHOD)).isEqualTo("GET");
assertThat(spanAttributes.get(HTTP_RESPONSE_STATUS_CODE)).isEqualTo(status);
assertThat(spanAttributes.get(ServerAttributes.SERVER_PORT)).isEqualTo(url.getPort());
assertThat(spanAttributes.get(ServerAttributes.SERVER_ADDRESS)).isEqualTo(url.getHost());
assertThat(spanAttributes.get(UrlAttributes.URL_FULL)).isEqualTo(url.toString());
assertThat(spanAttributes.get(HttpAttributes.HTTP_REQUEST_METHOD)).isEqualTo("GET");

if (responseBody != null) {
assertThat(span.getAttributes().get(HTTP_RESPONSE_BODY_SIZE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.splunk.rum;

import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_BODY_SIZE;
import static io.opentelemetry.semconv.incubating.HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

Expand Down
7 changes: 5 additions & 2 deletions splunk-otel-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ android {
dependencies {
api(platform(libs.opentelemetry.instrumentation.bom))
api(platform(libs.opentelemetry.bom))
api(libs.opentelemetry.android)
api(libs.opentelemetry.android.agent)
api(libs.opentelemetry.android.instrumentation.commonapi) // not included in agent

implementation(libs.opentelemetry.sdk)
implementation(libs.opentelemetry.api.incubator)
implementation(libs.opentelemetry.instrumentation.okhttp)
implementation(libs.opentelemetry.exporter.zipkin)
implementation(libs.opentelemetry.exporter.otlp)
implementation(libs.opentelemetry.exporter.logging)
implementation(libs.opentelemetry.semconv)
implementation(libs.opentelemetry.semconv.incubating)
implementation(libs.androidx.core)
implementation(libs.androidx.navigation.fragment)
api(libs.zipkin.sender.okhttp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ConfigFlags {
private boolean slowRenderingDetectionEnabled = true;
private boolean subprocessInstrumentationEnabled = true;
private boolean backgroundInstrumentationDeferredUntilForeground = false;
private boolean exportUsingOtlp = false;

void enableDebug() {
debugEnabled = true;
Expand Down Expand Up @@ -102,18 +101,6 @@ boolean isReactNativeSupportEnabled() {
return reactNativeSupportEnabled;
}

void enableOtlpExporter() {
exportUsingOtlp = true;
}

void disableOtlpExporter() {
exportUsingOtlp = false;
}

boolean shouldUseOtlpExporter() {
return exportUsingOtlp;
}

@NonNull
@Override
public String toString() {
Expand Down
Loading
Loading