Skip to content

Feature Request: Allow Explicit Configuration of service.name for Android RUM Instrumentation Problem #1301

@simplekjl

Description

@simplekjl

The current OpenTelemetry Android RUM SDK automatically determines the service.name resource attribute from the Android Manifest's android:label using applicationContext.applicationInfo.labelRes. This behavior is problematic for modern Android build setups.

In our configuration, and in many projects, the android:label uses placeholders (e.g., android:label="${appName}${appNameSuffix}") which are resolved at build time (e.g., via Gradle) and do not point to a string resource ID. Consequently, the internal readAppName function fails to retrieve a valid string, defaulting the service.name to "unknown_service:android".

Evidence of Limitation
The current implementation appears to rely on application.applicationContext.applicationInfo.labelRes, as shown in the provided snippet:


private fun readAppName(application: Application): String =
    try {
        val stringId =
            application.applicationContext.applicationInfo.labelRes
        application.applicationContext.getString(stringId) // Fails if labelRes is not a valid resource ID
    } catch (_: Exception) {
        DEFAULT_APP_NAME // Defaults to "unknown_service:android"
    }

Attempting to override the service.name via OtelRumConfig().setGlobalAttributes() is ineffective because the default Android resource attributes, including the problematic service.name derived from the Manifest, are applied after the GlobalAttributes provided in the configuration, or they are generated by AndroidResource.createDefault() which gets merged in a way that the Manifest-derived value takes precedence.

is there any other that the current implementation allows to change this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv1.0.0-requiredThis is required to reach v1.0.0 (stability)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions