Skip to content

Commit

Permalink
Merge pull request #149 from WebPlatformForEmbedded/development/Perfo…
Browse files Browse the repository at this point in the history
…rmanceMetrics

[PerfMetrics] initial commit
  • Loading branch information
MFransen69 authored Apr 10, 2022
2 parents b53ddb2 + 59d21df commit 27a5ffe
Show file tree
Hide file tree
Showing 16 changed files with 4,050 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ option(PLUGIN_LOCATIONSYNC "Include LocationSync plugin" OFF)
option(PLUGIN_MESSAGECONTROL "Include MessageControl plugin" OFF)
option(PLUGIN_MESSENGER "Include Messenger plugin" OFF)
option(PLUGIN_MONITOR "Include Monitor plugin" OFF)
option(PLUGIN_PERFORMANCEMETRICS "Include PerformanceMetrics plugin" OFF)
option(PLUGIN_OPENCDMI "Include OpenCDMi plugin" OFF)
option(PLUGIN_PACKAGER "Include Packager plugin" OFF)
option(PLUGIN_SECURITYAGENT "Include SecurityAgent plugin" OFF)
Expand Down Expand Up @@ -57,6 +58,10 @@ if(PLUGIN_MONITOR)
add_subdirectory(Monitor)
endif()

if(PLUGIN_PERFORMANCEMETRICS)
add_subdirectory(PerformanceMetrics)
endif()

if(PLUGIN_OPENCDMI)
add_subdirectory(OpenCDMi)
endif()
Expand Down
93 changes: 93 additions & 0 deletions PerformanceMetrics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

project(PerformanceMetrics)

cmake_minimum_required(VERSION 3.3)

find_package(WPEFramework)

project_version(1.0.0)

set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")

set(PLUGIN_PERFORMANCEMETRICS_AUTOSTART "true" CACHE STRING "Automatically start Performance Metrics plugin")
set(PLUGIN_PERFORMANCEMETRICS_LOGGER_IMPLEMENTATION "TRACING" CACHE STRING "Defines what implementation to use for logging the Performance Metrics")

# Plugins built from this repository that can be autmatically enabled or enabled manually when built externally
set(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER "${PLUGIN_WEBKITBROWSER}" CACHE BOOL "Enable monitor for the Performance Metrics plugin")
set(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_APPS "${PLUGIN_WEBKITBROWSER_APPS}" CACHE BOOL "Enable monitor for the Performance Metrics Apps plugin")
set(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_RESIDENT_APP "${PLUGIN_WEBKITBROWSER_RESIDENT_APP}" CACHE BOOL "Enable monitor for the Performance Metrics Resident App plugin")
set(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_UX "${PLUGIN_WEBKITBROWSER_UX}" CACHE BOOL "Enable monitor for the Performance Metrics UX plugin")
set(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_YOUTUBE "${PLUGIN_WEBKITBROWSER_YOUTUBE}" CACHE BOOL "Enable monitor for the Performance Metrics Youtube plugin")

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(CompileSettingsDebug CONFIG REQUIRED)

add_library(${MODULE_NAME} SHARED
PerformanceMetrics.cpp
Module.cpp)

if (PLUGIN_PERFORMANCEMETRICS_LOGGER_IMPLEMENTATION STREQUAL "TRACING")
message(STATUS "Outputting PerformanceMetrics to Tracing")
target_sources(${MODULE_NAME}
PRIVATE
TraceOutput.cpp)
elseif (PLUGIN_PERFORMANCEMETRICS_LOGGER_IMPLEMENTATION STREQUAL "SYSLOG")
message(STATUS "Outputting PerformanceMetrics to Syslog")
target_sources(${MODULE_NAME}
PRIVATE
SyslogOutput.cpp)
else()
message(FATAL_ERROR "There is no output implementation specified for the Performance Metrics plugin")
endif()

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES)

target_link_libraries(${MODULE_NAME}
PRIVATE
CompileSettingsDebug::CompileSettingsDebug
${NAMESPACE}Plugins::${NAMESPACE}Plugins)

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER)
write_config( PLUGINS PerfMetricsWebKitBrowser )
endif()

if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_APPS)
write_config( PLUGINS PerfMetricsApps )
endif()

if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_RESIDENT_APP)
write_config( PLUGINS PerfMetricsResidentApp )
endif()

if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_UX)
write_config( PLUGINS PerfMetricsUX )
endif()

if(PLUGIN_PERFORMANCEMETRICS_WEBKITBROWSER_YOUTUBE)
write_config( PLUGINS PerfMetricsYouTube )
endif()


22 changes: 22 additions & 0 deletions PerformanceMetrics/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "Module.h"

MODULE_NAME_DECLARATION(BUILD_REFERENCE)
28 changes: 28 additions & 0 deletions PerformanceMetrics/Module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#ifndef MODULE_NAME
#define MODULE_NAME Plugin_PerformanceMetrics
#endif

#include <plugins/plugins.h>

#undef EXTERNAL
#define EXTERNAL
7 changes: 7 additions & 0 deletions PerformanceMetrics/PerfMetricsApps.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(autostart ${PLUGIN_PERFORMANCEMETRICS_AUTOSTART})

map()
kv(callsign "Apps")
end()
ans(configuration)

7 changes: 7 additions & 0 deletions PerformanceMetrics/PerfMetricsResidentApp.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(autostart ${PLUGIN_PERFORMANCEMETRICS_AUTOSTART})

map()
kv(callsign "ResidentApp")
end()
ans(configuration)

7 changes: 7 additions & 0 deletions PerformanceMetrics/PerfMetricsUX.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(autostart ${PLUGIN_PERFORMANCEMETRICS_AUTOSTART})

map()
kv(callsign "UX")
end()
ans(configuration)

7 changes: 7 additions & 0 deletions PerformanceMetrics/PerfMetricsWebKitBrowser.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(autostart ${PLUGIN_PERFORMANCEMETRICS_AUTOSTART})

map()
kv(callsign "WebKitBrowser")
end()
ans(configuration)

7 changes: 7 additions & 0 deletions PerformanceMetrics/PerfMetricsYouTube.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(autostart ${PLUGIN_PERFORMANCEMETRICS_AUTOSTART})

map()
kv(callsign "YouTube")
end()
ans(configuration)

93 changes: 93 additions & 0 deletions PerformanceMetrics/PerformanceMetrics.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "PerformanceMetrics.h"

namespace WPEFramework {
namespace Plugin {

SERVICE_REGISTRATION(PerformanceMetrics, 1, 0);

const string PerformanceMetrics::Initialize(PluginHost::IShell* service)
{
ASSERT(service != nullptr);

Config config;
config.FromString(service->ConfigLine());

string result;

if( ( config.ObservableCallsign.IsSet() == true ) && ( config.ObservableCallsign.Value().empty() == false ) ) {
_callsign = config.ObservableCallsign.Value();
service->Register(&_notification);
} else {
result = _T("No callsign set to observe for metrics");
}

if( result.empty() == false ) {
Deinitialize(service);
}

return result;
}

void PerformanceMetrics::Deinitialize(PluginHost::IShell* service)
{
if( _callsign.empty() == false ) {
service->Unregister(&_notification);
// as we do this after the unregister this should be threadsafe
// if the deactivate of the observable did not happen we must clean up here
if( _observable.IsValid() == true ) {
_observable->Disable();
VARIABLE_IS_NOT_USED uint32_t result =_observable.Release();
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);
ASSERT(_observable.IsValid() == false);
}
_callsign.clear();
}
}

string PerformanceMetrics::Information() const
{
return (_T(""));
}

void PerformanceMetrics::ObservableActivated(PluginHost::IShell& service)
{
ASSERT(_observable.IsValid() == false);

CreateObservable(service);
_observable->Activated(service);
}

void PerformanceMetrics::ObservableDeactivated(PluginHost::IShell& service)
{
ASSERT(_observable.IsValid() == true);

_observable->Deactivated(service);
_observable->Disable();
VARIABLE_IS_NOT_USED uint32_t result =_observable.Release();
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED);
ASSERT(_observable.IsValid() == false);
}

constexpr char PerformanceMetrics::IBrowserMetricsLogger::startURL[];

}
}
Loading

0 comments on commit 27a5ffe

Please sign in to comment.