open-telemetry / opentelemetry-android

OpenTelemetry Tooling for Android
Apache License 2.0
150 stars 37 forks source link

Update following resource attributes - Service.name, Service.version, telemetry.sdk.name/language/version #12

Open surbhiia opened 1 year ago

surbhiia commented 1 year ago

I was looking at exported network traces by zipkin exporter from this repo’s source repo and came across the below items:

  1. service.name (required resource attribute) The value emitted today is “unknown_service:java” which is what’s coming from the opentelemetry-java sdk’s default resource. Class AndroidResource.java does overwrite it to make it specific to android, I also debugged the code and found that it works as intended and overwrites the value to the sample application’s name (“Splunk RUM Sample App”) but still zipkin exporter emits the java value. I also came across this which mentions how zipkin decides what to populate. Is it something that needs to be corrected in this repo (making sure the local root span has correct service.name) or something to be corrected in zipkin exporter?

  2. service.version (recommended resource attribute) It is missing today. I think it goes along with the service.name attribute and we can add this. App.version is being emitted from the source repo today, that value can be populated in service.version field.

  3. telemetry.sdk.name, telemetry.sdk.language, telemetry.sdk.version (required resource attributes) These attributes are present in the opentelemetry-java sdk’s default resource which we start with but we do not modify them to android sdk specific values. Should these be modified in AndroidResource.java class (rum.sdk.version could populate telemetry.sdk.version field?). Secondly, I do not see these attributes being emitted by Zipkin exporter - should these be emitted? If Yes, I can follow up with maintainers of zipkin exporter repo to understand more about why these are not emitted.

Attaching a sample okhttp3 (200 status code) trace emitted by the zipkin exporter from the source repo:

{"traceId":"716b0bedeea691fca26a22c75dc5806a", "parentId":"287eaa22bacb42f6", "id":"a88a576ce66b953f", "kind":"CLIENT", "name":"GET", "timestamp":1690584327638568, "duration":84051, "localEndpoint":{"serviceName":"unknown_service:java"}, "tags":{ "_splunk_operation":"GET", "app":"Android Demo App", "app.version":"1.0", "component":"http", "customerId":"123456", "deployment.environment":"demo", "device.model.identifier":"Android SDK built for arm64", "device.model.name":"Android SDK built for arm64", "http.method":"GET", "http.status_code":"200", "http.url":"https://pmrum.o11ystore.com/?user=&pass=", "link.spanId":"05d0aa28bf103013", "link.traceId":"000000000000000005d0aa28bf103013", "location.lat”:”XX.XX1998333333335", "location.long”:”XX.XX400000000002", "net.host.connection.subtype":"", "net.host.connection.type":"wifi", "net.peer.name":"pmrum.o11ystore.com", "net.protocol.name":"http", "net.protocol.version":"2.0", "os.name":"Android", "os.type":"linux", "os.version":"8.0.0", "otel.library.name":"io.opentelemetry.okhttp-3.0", "otel.library.version":"1.27.0-alpha-SNAPSHOT", "otel.scope.name":"io.opentelemetry.okhttp-3.0", "otel.scope.version":"1.27.0-alpha-SNAPSHOT", "rum.sdk.version":"1.1.0-SNAPSHOT", "rum.session.id":"0889effc6409b9ef84eb59c23943c781", "screen.name":"FirstFragment", "splunk.rumSessionId":"0889effc6409b9ef84eb59c23943c781", "user_agent.original":"okhttp/4.11.0", "vendor":"Splunk"} }

LikeTheSalad commented 1 year ago

Hi @surbhiia thanks for your feedback! - I believe this SDK should send both service.name and service.version resource attrs, and I also think the telemetry.sdk.* values should belong to this SDK as well (instead of the Java SDK ones) unless there's an important reason why not to that I might've missed.

Based on what you mentioned, it sounds as if some of the unexpected behavior that you experienced is related to how the Zipkin exporter works. I haven't checked it in detail so I can't tell if that's actually the issue, however, I just wanted to mention that the Zipkin exporter should not be the only option to use as exporter by the time this library's first version is released, as I think it is the case now, so if you're concerned about having to use the Zipkin exporter, I just wanted to mention that you won't have to. Now, in case the issues are not related to the Zipkin exporter then it's definitely something that we'll have to work on before the first release.

breedx-splk commented 1 year ago

Yeah +1 to what @LikeTheSalad said above about the zipkin bits. A lot of this will be in flux while we switch away from zipkin in otel-android to otlp.

Regarding the telemetry.sdk.* attributes -- there is a spec proposal over here to add two new attributes so that we don't overload/collide with the values from the sdk. Right now it's leaning toward telemetry.auto.name and telemetry.auto.version but I have also proposed telemetry.distro.name and telemetry.distro.version.

Please chime in over there if you have an opinion to share.

surbhiia commented 1 year ago

Thanks a lot for the clarification @LikeTheSalad and @breedx-splk! :)