Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5f1bdf0
Entities are defined for storing application logs
this-Aditya Feb 17, 2025
613a21e
Created data access objects for query access
this-Aditya Feb 17, 2025
2bde96b
Added converters for storing enums
this-Aditya Feb 17, 2025
4182fdb
Created a room database subclass
this-Aditya Feb 17, 2025
588871e
Action defined for starting ApplicationMetricsActivity for applicatio…
this-Aditya Feb 17, 2025
fdd4705
Created activity for showing application metrics
this-Aditya Feb 17, 2025
dbdca27
Created recyclerview adapter for showing string list
this-Aditya Feb 17, 2025
1bf36dd
Implemented paging-data-adapters for showing network and plugin logs
this-Aditya Feb 17, 2025
181d6ed
Layout files added for application metrics activity
this-Aditya Feb 17, 2025
e4c3c56
Value resources added
this-Aditya Feb 17, 2025
892b056
Adding created activity to the manifest file
this-Aditya Feb 17, 2025
448208e
Added viewmodel
this-Aditya Feb 17, 2025
3062664
Utility classes added
this-Aditya Feb 17, 2025
0669d32
Minor changes
this-Aditya Feb 17, 2025
7451d24
Application plugin will now also track source, network status and rec…
this-Aditya Feb 18, 2025
4c398f8
Configured data access objects to count numbers
this-Aditya Feb 19, 2025
6a2132b
Application plugin will now configure auto deletion of records from db
this-Aditya Feb 19, 2025
fd7021f
Tracking the plugin status
this-Aditya Feb 19, 2025
7f92290
Added new queries
this-Aditya Feb 19, 2025
c65c2ce
Providing default value for id
this-Aditya Feb 19, 2025
2cee143
Deleting logs after they are sent
this-Aditya Feb 19, 2025
dc17d3c
Some debug logs and adddtion of data sending components
this-Aditya Feb 19, 2025
9250775
Update to layouts
this-Aditya Feb 19, 2025
0658674
Some UI fixes and correcting adapter's view binding
this-Aditya Feb 19, 2025
c4933af
Updates to dao, entitites and specified correct reference in source s…
this-Aditya Feb 19, 2025
004cd82
Added support for room database and pagination
this-Aditya Feb 19, 2025
2d3413d
Added the schema corresponding to database tables
this-Aditya Feb 19, 2025
507b74f
Updates to readme and config parameters
this-Aditya Feb 19, 2025
a4a54c9
Deleted adapter classes from the plugin as it is not required
this-Aditya Mar 3, 2025
3d96fb6
Plugin configuration
this-Aditya Mar 3, 2025
3c32ac0
Avoiding concurrent modification exceptions and updated logs
this-Aditya Mar 3, 2025
57c602b
Update build
this-Aditya Mar 3, 2025
ee4fc72
Merging ktor-coroutines into app-metrics
this-Aditya Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ buildscript {
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_android_gradle_plugin_version"
classpath("org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version")
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "androidx.room:room-gradle-plugin:$room_version"
}
}

Expand Down Expand Up @@ -58,6 +59,7 @@ subprojects {
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'idea'
apply plugin: 'kotlin-kapt'

//---------------------------------------------------------------------------//
// Sources and classpath configurations //
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dokka_android_gradle_plugin_version=0.9.18
dokka_version=1.9.20
publish_plugin_version=2.0.0
versions_plugin_version=0.51.0
room_version=2.6.1
paging_version=3.3.6

radar_commons_version=1.1.2
radar_schemas_commons_version=0.8.11
Expand Down
35 changes: 21 additions & 14 deletions plugins/radar-android-application-status/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,27 @@ To activate this plugin, add the provider `application_status` to the Firebase R

This plugin takes the following Firebase configuration parameters:

| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| `ntp_server` | string | `<empty>` | NTP server to synchronize time with. If empty, time is not synchronized and the `application_external_time` topic will not receive data. |
| `application_status_update_rate` | int (seconds) | `300` = 5 minutes | Rate at which to send data for all application topics. |
| `application_send_ip` | boolean | `false` | Whether to send the device IP address with the server status. |
| `application_time_zone_update_rate` | int (seconds) | `86400` = 1 day | How often to send the current time zone. Set to `0` to disable. |
| Name | Type | Default | Description |
|------------------------------------------------|---------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ntp_server` | string | `<empty>` | NTP server to synchronize time with. If empty, time is not synchronized and the `application_external_time` topic will not receive data. |
| `application_status_update_rate` | int (seconds) | `300` = 5 minutes | Rate at which to send data for all application topics. |
| `application_send_ip` | boolean | `false` | Whether to send the device IP address with the server status. |
| `application_time_zone_update_rate` | int (seconds) | `86400` = 1 day | How often to send the current time zone. Set to `0` to disable. |
| `application_metrics_verification_update_rate` | int (seconds) | `300` = 5 minutes | Defines the interval for verifying that records older than application_metrics_retention_time are not present. Set to 0 to disable. |
| `application_metrics_buffer_size` | int (count) | `100` | Specifies the number of records to keep in the buffer before adding them to the database. Storing records in batches significantly improves performance. |
| `application_metrics_retention_time` | int (seconds) | `7*86400` = 7 day | Determines how long application metrics are retained in the database. Records older than this value are automatically deleted. |
| `application_metrics_data_retention_count` | int (seconds) | `10000` = 10000 records | Specifies the maximum number of messages to retain for application metrics in the database. When this limit is exceeded, older messages are deleted. |

This plugin produces data for the following topics: (types starts with `org.radarcns.monitor.application` prefix)

| Topic | Type | Description |
| ----- | ---- | ----------- |
| `application_external_time` | `ApplicationExternalTime` | External NTP time. Requires `ntp_server` parameter to be set. |
| `application_record_counts` | `ApplicationRecordCounts` | Number of records sent and in queue. |
| `application_uptime` | `ApplicationUptime` | Time since the device booted. |
| `application_server_status` | `ApplicationServerStatus` | Server connection status. |
| `application_time_zone` | `ApplicationTimeZone` | Application time zone. Data is only sent on updates. |
| `application_device_info` | `ApplicationDeviceInfo` | Device information. Data is only sent on updates. |
| Topic | Type | Description |
|----------------------------------|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `application_external_time` | `ApplicationExternalTime` | External NTP time. Requires `ntp_server` parameter to be set. |
| `application_record_counts` | `ApplicationRecordCounts` | Number of records sent and in queue. |
| `application_uptime` | `ApplicationUptime` | Time since the device booted. |
| `application_server_status` | `ApplicationServerStatus` | Server connection status. |
| `application_time_zone` | `ApplicationTimeZone` | Application time zone. Data is only sent on updates. |
| `application_device_info` | `ApplicationDeviceInfo` | Device information. Data is only sent on updates. |
| `application_network_status` | `ApplicationNetworkStatus` | Represents the network connectivity status of an application, indicating whether it is connected to the internet and, if so, whether the connection is via Wi-Fi or cellular data. |
| `application_plugin_status` | `ApplicationPluginStatus` | Represents the status of a plugin, indicating its current connection state. |
| `application_topic_records_sent` | `ApplicationTopicRecordsSent` | Number of records sent for the topic since the last upload |
22 changes: 22 additions & 0 deletions plugins/radar-android-application-status/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,31 @@ description = "Application statistics plugin for RADAR passive remote monitoring
// Sources and classpath configurations //
//---------------------------------------------------------------------------//

android {
buildFeatures {
viewBinding true
}
}

dependencies {
api project(":radar-commons-android")
implementation "androidx.localbroadcastmanager:localbroadcastmanager:$localbroadcastmanager_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "com.google.android.material:material:$material_version"
implementation "androidx.activity:activity:1.9.0"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation "androidx.legacy:legacy-support-v4:$legacy_support_version"
implementation 'androidx.fragment:fragment-ktx:1.8.1'

implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version" // For Kotlin Coroutines support

}

afterEvaluate {
tasks["dokkaJavadoc"].dependsOn(tasks.getByName("kaptReleaseKotlin"), tasks.getByName("kaptDebugKotlin"))
}

apply from: "$rootDir/gradle/publishing.gradle"
apply plugin: 'org.jetbrains.kotlin.android'
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<service android:name=".ApplicationStatusService"
android:exported="false"
android:description="@string/application_status_description" />
<activity
android:name=".ui.ApplicationMetricsActivity"
android:exported="false" />

<service
android:name=".ApplicationStatusService"
android:description="@string/application_status_description"
android:exported="false" />
</application>
</manifest>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ package org.radarbase.monitor.application

import org.radarbase.android.kafka.ServerStatus
import org.radarbase.android.source.BaseSourceState
import org.radarbase.android.storage.entity.NetworkStatusLog
import org.radarbase.android.storage.entity.SourceStatusLog
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicInteger

class ApplicationState : BaseSourceState() {

var uiManager: UserInterfaceManager? = null

val sourceStatusBufferCount: AtomicInteger = AtomicInteger(0)
val networkStatusBufferCount: AtomicInteger = AtomicInteger(0)

@set:Synchronized
var serverStatus: ServerStatus? = null
@Synchronized get() = field ?: ServerStatus.DISCONNECTED
Expand All @@ -29,10 +38,43 @@ class ApplicationState : BaseSourceState() {
var recordsSent = 0L
private set

val metricsCountPerTopic: MutableMap<String, Long> = ConcurrentHashMap()
val cachedRecords: MutableMap<String, Long> = ConcurrentHashMap()
val recordsSentPerTopic: MutableMap<String, Long> = ConcurrentHashMap()
private val sourceStatusBuffer: MutableList<SourceStatusLog> = mutableListOf()
private val networkStatusBuffer: MutableList<NetworkStatusLog> = mutableListOf()

fun addSourceStatus(status: SourceStatusLog) {
sourceStatusBuffer.add(status)
}

fun clearSourceStatuses() {
sourceStatusBuffer.clear()
}

fun clearNetworkStatuses() {
networkStatusBuffer.clear()
}

fun getSourceStatuses(): List<SourceStatusLog> {
return sourceStatusBuffer
}

fun addNetworkStatus(status: NetworkStatusLog) {
networkStatusBuffer.add(status)
}

fun getNetworkStatuses(): List<NetworkStatusLog> {
return networkStatusBuffer
}

@Synchronized
fun addRecordsSent(nRecords: Long) {
recordsSent += nRecords
}

interface UserInterfaceManager {
fun sendSourceStatus()
fun sendNetworkStatus()
}
}
Loading