-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Problem Statement
Currently, carrier attributes (network.carrier.name, network.carrier.mcc, network.carrier.mnc, network.carrier.icc) are only included in network spans when the device is actively connected via cellular network. However, SIM card information is available via TelephonyManager regardless of the active connection type (WiFi, VPN, Ethernet, etc.).
This means that when a device with a SIM card is connected via WiFi, valuable carrier information is lost, even though it's technically available and could provide useful context for telemetry data.
Expected Behavior
When a device has a SIM card installed, carrier attributes should be included in network spans regardless of the active connection type (WiFi, VPN, Ethernet, or Cellular). This would provide consistent carrier information across all network connection types.
Current Behavior
- ✅ Carrier attributes are included when connected via cellular network
- ❌ Carrier attributes are missing when connected via WiFi (even with SIM card present)
- ❌ Carrier attributes are missing when connected via VPN/Ethernet (even with SIM card present)
Proposed Solution
Modify the buildNetwork() method in NetworkDetectorImpl.kt to also retrieve carrier information using CarrierFinder, similar to how buildCellularNetwork() does it.
Current implementation:
private fun buildNetwork(networkState: NetworkState) = CurrentNetwork(networkState)
Proposed implementation:
private fun buildNetwork(networkState: NetworkState): CurrentNetwork {
val carrier = carrierFinder.get()
return CurrentNetwork(
state = networkState,
carrier = carrier,
)
}
Technical Details
- SIM card information is accessible via
TelephonyManagerregardless of active network type - The
CarrierFinderclass already handles permission checks and API level differences - This change would be backward compatible (carrier will be
nullif no SIM card or permissions are missing) - No additional permissions are required beyond what's already needed for cellular connections
Use Case
This is particularly useful for:
- Mobile apps that primarily use WiFi but need carrier information for analytics/telemetry
- Enterprise applications tracking device context across different network types
- Consistent telemetry data regardless of connection type
Additional Context
The CarrierFinder class already exists and handles edge cases (missing permissions, no telephony feature, etc.), so this change would leverage existing infrastructure.
Related Files
services/src/main/java/io/opentelemetry/android/internal/services/network/detector/NetworkDetectorImpl.ktservices/src/main/java/io/opentelemetry/android/internal/services/network/CarrierFinder.java