opentelemetry-java
opentelemetry-java copied to clipboard
More information on how to implement in android
I don't see much documentation on how to implement it in android, neither blogs nor communities, I don't find much info.
like this
I think nobody we know of has tried it & reported back so far. Did you try it and hit any roadblocks?
Splunk is using otel extensively in our new RUM instrumentation for Android. There isn't really much special about it. It pretty well works out of the box as it should.
Have you had any issues @juliandavid333 ?
FYI: https://github.com/signalfx/splunk-otel-android
FYI: https://github.com/signalfx/splunk-otel-android
thank you, let me try
I've been experimenting with version 1.6.0 on Android and, since our min API level is 23, it fails at runtime with this exception.
E java.lang.NoClassDefFoundError: io.opentelemetry.api.common.ArrayBackedAttributes$$ExternalSyntheticLambda0
E at io.opentelemetry.api.common.ArrayBackedAttributes.<clinit>(ArrayBackedAttributes.java:20)
E at io.opentelemetry.api.common.Attributes$-CC.of(Attributes.java:62)
E ...
The static method isn't supported on Android until API 24.
Is the min API of 24 a hard minimum? What other APIs are only on 24 that this library is depending on? Just looking to get more clarification on the minimum.
@kylannjohnson You must enable core library desugaring in your app build for this to work. https://developer.android.com/studio/write/java8-support#library-desugaring
And with that enabled, anything API level 21 and above should work fine.
@jkwatson thanks for the tip. Desugaring does seem to quiet the exception. I asked around on my team and we haven't desugared to date because of potential licensing issues with OpenJDK. I'll certainly investigate that on my side, but I was wondering what the scope was for adaption o Open Telemetry to api 23 or api 21. Do you think it's feasible?
Licensing issues for OpenJdk? I'm not sure how that's relevant for Android's desugaring of java 8 APIs.
I'm not sure what you mean by your question. You mean...what would it take to not have to do desugaring? That ship sailed long, long ago. We made the decision to support only java 8+, and that is not going to change. It would require a radical rewrite of almost all of our public APIs which depend extensively on interfaces being able to have static methods.
which depend extensively on interfaces being able to have static methods.
You don't need code lib desugaring to support the language features, like lambdas, default methods on interfaces, etc. R8 gives you all the Java 8 syntax support for all Android builds.
Core lib desugaring is only needed when you call a JDK API that was introduced in Java 8. For example: https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#comparing-java.util.function.Function-
So as long as you don't use JDK APIs that are from Java 8+, you could still use java 8 syntax and support Android without core lib desugaring.
I see. But, your example stack trace was specifically about static methods on interfaces. :) Are you saying that for API level 21-24, you can only target Java 8 language level in your build, and it will work, without desugaring?
@yogurtearl Please let us know what your findings on potential legal issues are. We made the decision to target deaugared libs after the Gradle Android plugin was updated to support desugaring for all API versions. Our understanding was that this means there isn't any reason for users not to enable this so that OTel would work while allowing us to provide a modern experience for Java users (e.g., accept Duration
in public API). It would be good for us to know about any potential non-technical issues - though I don't think we would really be able to do anything as at this point the desugaring requirement is broadly ingrained into the codebase, including public APIs.
@kylannjohnson were you able to make it work for android?
@jkwatson what changes will be needed to make splunk-otel-android
send data to jaeger
? I see the readme mention something like below
private final Config config = SplunkRum.newConfigBuilder()
.realm(realm)
.rumAccessToken(rumAccessToken)
.applicationName("My Android App")
.build();
@kylannjohnson were you able to make it work for android?
@jkwatson what changes will be needed to make
splunk-otel-android
send data tojaeger
? I see the readme mention something like belowprivate final Config config = SplunkRum.newConfigBuilder() .realm(realm) .rumAccessToken(rumAccessToken) .applicationName("My Android App") .build();
I no longer work for Splunk, so you should probably create an issue in their project if you need help with that.
@kylannjohnson were you able to make it work for android?
I was just experimenting with OTEL so I wasn't able to complete that project, but I'll post back here if I'm able to get something working.
Closing now that there is an official opentelemetry-android project.