forked from rdkcentral/rdkservices
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from WebPlatformForEmbedded/development/Perfo…
…rmanceMetrics [PerfMetrics] initial commit
- Loading branch information
Showing
16 changed files
with
4,050 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
|
||
} | ||
} |
Oops, something went wrong.