Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 42 additions & 26 deletions AppManager/AppManagerTelemetryReporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace WPEFramework
{
namespace Plugin
{
AppManagerTelemetryReporting::AppManagerTelemetryReporting(): mTelemetryMetricsObject(nullptr), mCurrentservice(nullptr)
AppManagerTelemetryReporting::AppManagerTelemetryReporting(): mTelemetryPluginObject(nullptr), mCurrentservice(nullptr)
{
}

Expand All @@ -46,9 +46,9 @@ namespace Plugin
mAdminLock.Lock();
mCurrentservice = service;
mAdminLock.Unlock();
if(Core::ERROR_NONE != createTelemetryMetricsPluginObject())
if(Core::ERROR_NONE != createTelemetryPluginObject())
{
LOGERR("Failed to create TelemetryMetricsObject\n");
LOGERR("Failed to create TelemetryObject\n");
}
}

Expand All @@ -59,7 +59,7 @@ namespace Plugin
return ((time_t)(ts.tv_sec * 1000) + ((time_t)ts.tv_nsec/1000000));
}

Core::hresult AppManagerTelemetryReporting::createTelemetryMetricsPluginObject()
Core::hresult AppManagerTelemetryReporting::createTelemetryPluginObject()
{
Core::hresult status = Core::ERROR_GENERAL;

Expand All @@ -68,14 +68,14 @@ namespace Plugin
{
LOGERR("mCurrentservice is null \n");
}
else if (nullptr == (mTelemetryMetricsObject = mCurrentservice->QueryInterfaceByCallsign<WPEFramework::Exchange::ITelemetryMetrics>("org.rdk.TelemetryMetrics")))
else if (nullptr == (mTelemetryPluginObject = mCurrentservice->QueryInterfaceByCallsign<WPEFramework::Exchange::ITelemetry>("org.rdk.Telemetry")))
{
LOGERR("Failed to create TelemetryMetricsObject\n");
LOGERR("Failed to create TelemetryObject\n");
}
else
{
status = Core::ERROR_NONE;
LOGINFO("created TelemetryMetrics Object");
LOGINFO("created Telemetry Object");
}
mAdminLock.Unlock();
return status;
Expand All @@ -86,19 +86,20 @@ namespace Plugin
JsonObject jsonParam;
std::string telemetryMetrics = "";
std::string markerName = "";
std::string appMarker = "";
time_t currentTime = getCurrentTimestamp();
AppManagerImplementation*appManagerImplInstance = AppManagerImplementation::getInstance();

if(nullptr == mTelemetryMetricsObject) /*mTelemetryMetricsObject is null retry to create*/
if(nullptr == mTelemetryPluginObject) /*mTelemetryPluginObject is null retry to create*/
{
if(Core::ERROR_NONE != createTelemetryMetricsPluginObject())
if(Core::ERROR_NONE != createTelemetryPluginObject())
{
LOGERR("Failed to create TelemetryMetricsObject\n");
LOGERR("Failed to create TelemetryObject\n");
}
}

auto it = appManagerImplInstance->mAppInfo.find(appId);
if((it != appManagerImplInstance->mAppInfo.end()) && (currentAction == it->second.currentAction) && (nullptr != mTelemetryMetricsObject))
if((it != appManagerImplInstance->mAppInfo.end()) && (currentAction == it->second.currentAction) && (nullptr != mTelemetryPluginObject))
{
LOGINFO("Received data for appId %s current action %d ",appId.c_str(), currentAction);

Expand Down Expand Up @@ -129,16 +130,18 @@ namespace Plugin

if(!markerName.empty())
{
jsonParam["markerName"] = markerName;
jsonParam.ToString(telemetryMetrics);
if(!telemetryMetrics.empty())
{
mTelemetryMetricsObject->Record(appId, telemetryMetrics, markerName);
appMarker = appId + ":" + markerName;
mTelemetryPluginObject->Record(appMarker, telemetryMetrics);
}
}
}
else
{
LOGERR("Failed to report telemetry data as appId/currentAction or mTelemetryMetricsObject is not valid");
LOGERR("Failed to report telemetry data as appId/currentAction or mTelemetryPluginObject is not valid");
}
}

Expand All @@ -147,19 +150,20 @@ namespace Plugin
JsonObject jsonParam;
std::string telemetryMetrics = "";
std::string markerName = "";
std::string appMarker = "";
time_t currentTime = getCurrentTimestamp();
AppManagerImplementation*appManagerImplInstance = AppManagerImplementation::getInstance();

if(nullptr == mTelemetryMetricsObject) /*mTelemetryMetricsObject is null retry to create*/
if(nullptr == mTelemetryPluginObject) /*mTelemetryPluginObject is null retry to create*/
{
if(Core::ERROR_NONE != createTelemetryMetricsPluginObject())
if(Core::ERROR_NONE != createTelemetryPluginObject())
{
LOGERR("Failed to create TelemetryMetricsObject\n");
LOGERR("Failed to create TelemetryObject\n");
}
}

auto it = appManagerImplInstance->mAppInfo.find(appId);
if((it != appManagerImplInstance->mAppInfo.end()) && (nullptr != mTelemetryMetricsObject))
if((it != appManagerImplInstance->mAppInfo.end()) && (nullptr != mTelemetryPluginObject))
{
switch(it->second.currentAction)
{
Expand All @@ -168,6 +172,7 @@ namespace Plugin
{
jsonParam["totalLaunchTime"] = (int)(currentTime - it->second.currentActionTime);
jsonParam["launchType"] = ((AppManagerImplementation::APPLICATION_TYPE_INTERACTIVE == it->second.packageInfo.type)?"LAUNCH_INTERACTIVE":"START_SYSTEM");
jsonParam["markerFilters"] = TELEMETRY_MARKER_LAUNCH_TIME_FILTER;
markerName = TELEMETRY_MARKER_LAUNCH_TIME;
}
break;
Expand All @@ -176,6 +181,7 @@ namespace Plugin
{
jsonParam["totalLaunchTime"] = (int)(currentTime - it->second.currentActionTime);
jsonParam["launchType"] = ((AppManagerImplementation::APPLICATION_TYPE_INTERACTIVE == it->second.packageInfo.type)?"PRELOAD_INTERACTIVE":"START_SYSTEM");
jsonParam["markerFilters"] = TELEMETRY_MARKER_LAUNCH_TIME_FILTER;
markerName = TELEMETRY_MARKER_LAUNCH_TIME;
}
break;
Expand All @@ -186,6 +192,7 @@ namespace Plugin
{
jsonParam["totalCloseTime"] = (int)(currentTime - it->second.currentActionTime);
jsonParam["closeType"] = ((AppManagerImplementation::APP_ACTION_CLOSE == it->second.currentAction)?"CLOSE":((AppManagerImplementation::APP_ACTION_TERMINATE == it->second.currentAction)?"TERMINATE":"KILL"));
jsonParam["markerFilters"] = TELEMETRY_MARKER_CLOSE_TIME_FILTER;
markerName = TELEMETRY_MARKER_CLOSE_TIME;
}
break;
Expand All @@ -199,17 +206,20 @@ namespace Plugin
jsonParam["appId"] = appId;
jsonParam["appInstanceId"] = it->second.appInstanceId;
jsonParam["appVersion"] = it->second.packageInfo.version;
jsonParam["secondaryId"] = "appInstanceId";
jsonParam["markerName"] = markerName;
jsonParam.ToString(telemetryMetrics);
if(!telemetryMetrics.empty())
{
mTelemetryMetricsObject->Record(appId, telemetryMetrics, markerName);
mTelemetryMetricsObject->Publish(appId, markerName);
appMarker = appId + ":" + markerName;
mTelemetryPluginObject->Record(appMarker, telemetryMetrics);
mTelemetryPluginObject->Publish(appMarker);
}
}
}
else
{
LOGERR("Failed to report telemetry data as appId/mTelemetryMetricsObject is not valid");
LOGERR("Failed to report telemetry data as appId/mTelemetryPluginObject is not valid");
}
}

Expand All @@ -218,41 +228,47 @@ namespace Plugin
JsonObject jsonParam;
std::string telemetryMetrics = "";
std::string markerName = "";
std::string appMarker = "";

LOGINFO("Received data for appId %s current action %d app errorCode %d",appId.c_str(), currentAction, errorCode);

if(nullptr == mTelemetryMetricsObject) /*mTelemetryMetricsObject is null retry to create*/
if(nullptr == mTelemetryPluginObject) /*mTelemetryPluginObject is null retry to create*/
{
if(Core::ERROR_NONE != createTelemetryMetricsPluginObject())
if(Core::ERROR_NONE != createTelemetryPluginObject())
{
LOGERR("Failed to create TelemetryMetricsObject\n");
LOGERR("Failed to create TelemetryObject\n");
}
}

switch(currentAction)
{
case AppManagerImplementation::APP_ACTION_LAUNCH:
case AppManagerImplementation::APP_ACTION_PRELOAD:
jsonParam["markerFilters"] = TELEMETRY_MARKER_LAUNCH_ERROR_FILTER;
markerName = TELEMETRY_MARKER_LAUNCH_ERROR;
break;
case AppManagerImplementation::APP_ACTION_CLOSE:
case AppManagerImplementation::APP_ACTION_TERMINATE:
case AppManagerImplementation::APP_ACTION_KILL:
jsonParam["markerFilters"] = TELEMETRY_MARKER_CLOSE_ERROR_FILTER;
markerName = TELEMETRY_MARKER_CLOSE_ERROR;
break;
default:
LOGERR("currentAction is invalid");
break;
}

if(!markerName.empty() && (nullptr != mTelemetryMetricsObject))
if(!markerName.empty() && (nullptr != mTelemetryPluginObject))
{
jsonParam["errorCode"] = (int)errorCode;
jsonParam["secondaryId"] = "appInstanceId";
jsonParam["markerName"] = markerName;
jsonParam.ToString(telemetryMetrics);
if(!telemetryMetrics.empty())
{
mTelemetryMetricsObject->Record(appId, telemetryMetrics, markerName);
mTelemetryMetricsObject->Publish(appId, markerName);
appMarker = appId + ":" + markerName;
mTelemetryPluginObject->Record(appMarker, telemetryMetrics);
mTelemetryPluginObject->Publish(appMarker);
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions AppManager/AppManagerTelemetryReporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@
#pragma once

#include "AppManagerImplementation.h"
#include <interfaces/ITelemetryMetrics.h>
#include <interfaces/ITelemetry.h>

#define TELEMETRY_MARKER_LAUNCH_TIME "OverallLaunchTime_split"
#define TELEMETRY_MARKER_LAUNCH_ERROR "AppLaunchError_split"
#define TELEMETRY_MARKER_CLOSE_TIME "AppCloseTime_split"
#define TELEMETRY_MARKER_CLOSE_ERROR "AppCloseError_split"
#define TELEMETRY_MARKER_APP_CRASHED "AppCrashed_split"

#define TELEMETRY_MARKER_LAUNCH_TIME_FILTER "totalLaunchTime,appManagerLaunchTime,packageManagerLockTime,lifecycleManagerSpawnTime,windowManagerCreateDisplayTime,runtimeManagerRunTime,storageManagerLaunchTime,fireboltGatewayLaunchTime,appId,appInstanceId,appVersion,runtimeId,runtimeVersion,launchType,markerName"
#define TELEMETRY_MARKER_LAUNCH_ERROR_FILTER "errorCode,markerName"
#define TELEMETRY_MARKER_CLOSE_TIME_FILTER "totalCloseTime,appManagerCloseTime,packageManagerUnlockTime,lifecycleManagerSetTargetStateTime,windowManagerDestroyTime,runtimeManagerTerminateTime,storageManagerTime,fireboltGatewayTerminateTime,appId,appInstanceId,appVersion,closeType,markerName"
#define TELEMETRY_MARKER_CLOSE_ERROR_FILTER "errorCode,markerName"

namespace WPEFramework
{
namespace Plugin
Expand All @@ -48,11 +53,11 @@ class AppManagerTelemetryReporting
private /*methods*/:
AppManagerTelemetryReporting();
~AppManagerTelemetryReporting();
Core::hresult createTelemetryMetricsPluginObject();
Core::hresult createTelemetryPluginObject();

private /*members*/:
mutable Core::CriticalSection mAdminLock;
Exchange::ITelemetryMetrics* mTelemetryMetricsObject;
Exchange::ITelemetry* mTelemetryPluginObject;
PluginHost::IShell* mCurrentservice;
};

Expand Down
2 changes: 1 addition & 1 deletion AppManager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(PLUGIN_APP_MANAGER_MODE "Off" CACHE STRING "Controls if the plugin should ru
set(PLUGIN_APP_MANAGER_AUTOSTART false CACHE STRING "Automatically start AppManager plugin")
set(PLUGIN_APP_MANAGER_EXTRA_LIBRARIES "")
set(PLUGIN_APP_MANAGER_STARTUPORDER "" CACHE STRING "Automatically start AppManager plugin")
option(AIMANAGERS_TELEMETRY_METRICS_SUPPORT "AIMANAGERS_TELEMETRY_METRICS_SUPPORT" OFF)
option(AIMANAGERS_TELEMETRY_METRICS_SUPPORT "AIMANAGERS_TELEMETRY_METRICS_SUPPORT" ON)

add_definitions(-DAPP_MANAGER_API_VERSION_NUMBER_MAJOR=1)
add_definitions(-DAPP_MANAGER_API_VERSION_NUMBER_MINOR=0)
Expand Down
2 changes: 1 addition & 1 deletion LifecycleManager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(PLUGIN_LIFECYCLE_MANAGER_MODE "Local" CACHE STRING "Controls if the plugin s
set(PLUGIN_LIFECYCLE_MANAGER_AUTOSTART false CACHE STRING "Automatically start LifecycleManager plugin")
set(PLUGIN_LIFECYCLE_MANAGER_EXTRA_LIBRARIES "")
set(PLUGIN_LIFECYCLE_MANAGER_STARTUPORDER "" CACHE STRING "Automatically start LifecycleManager plugin")
option(AIMANAGERS_TELEMETRY_METRICS_SUPPORT "AIMANAGERS_TELEMETRY_METRICS_SUPPORT" OFF)
option(AIMANAGERS_TELEMETRY_METRICS_SUPPORT "AIMANAGERS_TELEMETRY_METRICS_SUPPORT" ON)

add_definitions(-DLIFECYCLE_MANAGER_API_VERSION_NUMBER_MAJOR=1)
add_definitions(-DLIFECYCLE_MANAGER_API_VERSION_NUMBER_MINOR=0)
Expand Down
Loading
Loading