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

Enable manual creation of screen view spans #851

Merged
merged 8 commits into from
Jun 17, 2024

Conversation

jtmalinowski
Copy link
Contributor

No description provided.

@jtmalinowski jtmalinowski requested review from a team as code owners June 6, 2024 15:40
Copy link

github-actions bot commented Jun 6, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@jtmalinowski
Copy link
Contributor Author

Currently builds and runs, but crashes on navigation to the JetpackComposeActivity, presumably because of some missing runtime dependency.

@jtmalinowski
Copy link
Contributor Author

@breedx-splk @laurit hey!

@jtmalinowski jtmalinowski force-pushed the jetpack-compose-support branch 4 times, most recently from 7828651 to c6dfded Compare June 10, 2024 12:14
@jtmalinowski jtmalinowski changed the title Jetpack compose support sketch Jetpack compose support Jun 10, 2024
@jtmalinowski
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

srv-gh-o11y-gdi-cla added a commit to splunk/cla-agreement that referenced this pull request Jun 10, 2024
@jtmalinowski jtmalinowski force-pushed the jetpack-compose-support branch from c6dfded to 053e0ec Compare June 10, 2024 12:19
@jtmalinowski jtmalinowski changed the title Jetpack compose support Enable manual creation of screen view spans Jun 10, 2024
Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should hold on this for now. Once the upstream repo has finished the instrumentation refactor/reorg, we should circle back to see how we do this custom screen name setting up there.

If we absolutely need to proceed with this for some immediate thing, we must be clear that it's experimental and will break/change shortly.

settings.gradle.kts Outdated Show resolved Hide resolved

import io.opentelemetry.android.instrumentation.activity.VisibleScreenTracker;

public class ExplicitVisibleScreenNameTracker extends VisibleScreenTracker {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this type of polymorphic inheritance can become problematic. Would much prefer to use delegation, and I think that long term perhaps VisibleScreenTracker needs to migrate to an interface (or two). I also wouldn't want to count on VisibleScreenTracker remaining an external API class for too long, things are in flux over there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, how would you implement delegation here? For example when we construct StartTypeAwareMemorySpanBuffer it wants an instance of VisibleScreenTracker, same with ScreenAttributesSpanProcessor, right? So with the existing API I need something that extends VisibleScreenTracker anyway? I'm open to ideas.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! Moved the logic to a span processor, so we don't have the inheritance anymore.

@@ -184,12 +188,22 @@ public LiveData<String> getSessionId() {
public void onDestroyView() {
super.onDestroyView();
binding = null;

SplunkRum.getInstance().setScreenName(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the existing Fragments unchanged and if anything make a new one to demonstrate the behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added a link to my new activity, where I added Jetpack Compose Navigation, so I think this is now addressed.

@@ -86,7 +88,7 @@ class RumInitializer {
}

SplunkRum initialize(Looper mainLooper) {
VisibleScreenTracker visibleScreenTracker = new VisibleScreenTracker();
ExplicitVisibleScreenNameTracker visibleScreenTracker = new ExplicitVisibleScreenNameTracker();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also something that will need to change, based on divergence from the upstream base code. The VisibleScreenTracker is also created by the OpenTelemetryRumBuilder, so we'd need to figure out how to NOT have two instances in play.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! For now the only usage, ie. https://github.com/open-telemetry/opentelemetry-android/blob/main/android-agent/src/main/java/io/opentelemetry/android/OpenTelemetryRumBuilder.java#L484 is addressed, because we replace their ScreenAttributesSpanProcessor with our own.

@jtmalinowski
Copy link
Contributor Author

we must be clear that it's experimental and will break/change shortly.

In browser RUM we had experimental prefix for cases like this, so the signature would become:

public void experimentalSetScreenName(String screenName) {

I think it's fair to assume that this functionality might be unavailable in some versions as OTel is being restructured, I'll rebuild it when we know the new API. Perhaps even OTel itself will have something for Jetpack Compose in the near future.

So overall I think it's a good compromise, where customers are able to instrument Jetpack Compose via a workaround and under the new API we'll look at it again.

@jtmalinowski
Copy link
Contributor Author

I managed to configure the kotlin compiler after all, so the example is an actual Jetpack Compose Activity.

@jtmalinowski jtmalinowski requested a review from breedx-splk June 14, 2024 15:13
@@ -113,6 +117,23 @@ static SplunkRum initialize(SplunkRumBuilder builder, Application application) {
return INSTANCE;
}

public void experimentalSetScreenName(String screenName, String spanType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two new public API methods needs javadoc so that users can get a better idea about what they do and when they should/shouldn't use these.

Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's experiment!

@breedx-splk breedx-splk merged commit 8db73d9 into signalfx:main Jun 17, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants