IceLoggingStrategy.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 * This file is part of ArmarX.
5 *
6 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
7 *
8 * ArmarX is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * ArmarX is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * @package ArmarXCore::core::services::profiler
21 * @author Manfred Kroehnert ( manfred dot kroehnert at dot kit dot edu )
22 * @date 2015
23 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
24 * GNU General Public License
25 */
26
27
28#include <stdint.h> // for uint64_t
29
30#include <mutex>
31#include <string> // for string, operator<<
32#include <vector> // for vector
33
34#include <sys/types.h> // for pid_t, u_int64_t
35
36#include "ArmarXCore/interface/statechart/StatechartIce.h"
37#include <ArmarXCore/interface/core/Profiler.h>
38
39#include "../../services/tasks/PeriodicTask.h" // for PeriodicTask, etc
40#include "LoggingStrategy.h" // for LoggingStrategy
41
42namespace armarx::Profiler
43{
45
46 using IceLoggingStrategyPtr = std::shared_ptr<IceLoggingStrategy>;
47
48 /**
49 * @class IceLoggingStrategy
50 * @ingroup Profiling
51 * @brief IceLoggingStrategy publishes incoming log method calls directly on IceLoggingStrategy::profilerListenerPrx.
52 *
53 * Instances of this strategy object is used by armarx::Profiler.
54 */
55 class IceLoggingStrategy : virtual public LoggingStrategy
56 {
57 public:
58 IceLoggingStrategy(ProfilerListenerPrx profilerTopic);
59
60 ~IceLoggingStrategy() override;
61
62 void logEvent(pid_t processId,
63 uint64_t timestamp,
64 const std::string& executableName,
65 const std::string& timestampUnit,
66 const std::string& eventName,
67 const std::string& parentName,
68 const std::string& functionName) override;
69
70 void logStatechartTransition(const ProfilerStatechartTransition& transition) override;
71 void
72 logStatechartInputParameters(pid_t processId,
73 uint64_t timestamp,
74 const std::string& stateIdentifier,
75 const armarx::StateParameterMap& inputParameterMap) override;
76 void
77 logStatechartLocalParameters(pid_t processId,
78 uint64_t timestamp,
79 const std::string& stateIdentifier,
80 const armarx::StateParameterMap& localParameterMap) override;
81 void
82 logStatechartOutputParameters(pid_t processId,
83 uint64_t timestamp,
84 const std::string& stateIdentifier,
85 const armarx::StateParameterMap& outputParameterMap) override;
86
87 void logStatechartTransitionWithParameters(pid_t processId,
88 uint64_t timestamp,
89 const TransitionIceBase& transition) override;
90
91 void logProcessCpuUsage(pid_t processId, uint64_t timestamp, float cpuUsage) override;
92 void logProcessMemoryUsage(pid_t processId, u_int64_t timestamp, int memoryUsage) override;
93
94 protected:
95 ProfilerListenerPrx profilerListenerPrx;
96 };
97
98 /**
99 * @class IceBufferdLoggingStrategy
100 * @ingroup Profiling
101 * @brief IceBufferdLoggingStrategy buffers incoming log method calls and publishes them as collections on IceLoggingStrategy::profilerListenerPrx.
102 *
103 * Instances of this strategy object is used by armarx::Profiler.
104 */
106 {
107 public:
108 IceBufferedLoggingStrategy(ProfilerListenerPrx profilerTopic);
109
111
112 void logEvent(pid_t processId,
113 uint64_t timestamp,
114 const std::string& executableName,
115 const std::string& timestampUnit,
116 const std::string& eventName,
117 const std::string& parentName,
118 const std::string& functionName) override;
119
120 void logStatechartTransition(const ProfilerStatechartTransition& transition) override;
121 void
122 logStatechartInputParameters(pid_t processId,
123 uint64_t timestamp,
124 const std::string& stateIdentifier,
125 const armarx::StateParameterMap& inputParameterMap) override;
126 void
127 logStatechartLocalParameters(pid_t processId,
128 uint64_t timestamp,
129 const std::string& stateIdentifier,
130 const armarx::StateParameterMap& localParameterMap) override;
131 void
132 logStatechartOutputParameters(pid_t processId,
133 uint64_t timestamp,
134 const std::string& stateIdentifier,
135 const armarx::StateParameterMap& outputParameterMap) override;
136
137 void logStatechartTransitionWithParameters(pid_t processId,
138 uint64_t timestamp,
139 const TransitionIceBase& transition) override;
140
141 void logProcessCpuUsage(pid_t processId, uint64_t timestamp, float cpuUsage) override;
142 void logProcessMemoryUsage(pid_t processId, u_int64_t timestamp, int memoryUsage) override;
143
144 static ProfilerStatechartTransitionWithParameters
145 toProfilerTransition(pid_t processId,
146 uint64_t timestamp,
147 const TransitionIceBase& transition);
148
149 protected:
150 void publishData();
151 static armarx::StateParameterMap copyDictionary(const armarx::StateParameterMap& source);
152
153
155 ProfilerEventList profilerEvents;
156
158 ProfilerStatechartTransitionList profilerStatechartTransitions;
159
161 ProfilerStatechartParametersList profilerStatechartInputParameters;
162
164 ProfilerStatechartParametersList profilerStatechartLocalParameters;
165
167 ProfilerStatechartParametersList profilerStatechartOutputParameters;
168
170 ProfilerStatechartTransitionWithParametersList profilerStatechartTransitionsWithParameters;
171
173 ProfilerProcessCpuUsageList profilerProcessCpuUsages;
174
176 ProfilerProcessMemoryUsageList profilerProcessMemoryUsages;
177
178 ProfilerListenerPrx profilerListenerPrx;
179
181 };
182} // namespace armarx::Profiler
std::string timestamp()
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
void logStatechartTransitionWithParameters(pid_t processId, uint64_t timestamp, const TransitionIceBase &transition) override
void logStatechartOutputParameters(pid_t processId, uint64_t timestamp, const std::string &stateIdentifier, const armarx::StateParameterMap &outputParameterMap) override
ProfilerProcessMemoryUsageList profilerProcessMemoryUsages
void logStatechartInputParameters(pid_t processId, uint64_t timestamp, const std::string &stateIdentifier, const armarx::StateParameterMap &inputParameterMap) override
void logEvent(pid_t processId, uint64_t timestamp, const std::string &executableName, const std::string &timestampUnit, const std::string &eventName, const std::string &parentName, const std::string &functionName) override
void logProcessCpuUsage(pid_t processId, uint64_t timestamp, float cpuUsage) override
void logStatechartLocalParameters(pid_t processId, uint64_t timestamp, const std::string &stateIdentifier, const armarx::StateParameterMap &localParameterMap) override
static armarx::StateParameterMap copyDictionary(const armarx::StateParameterMap &source)
ProfilerStatechartParametersList profilerStatechartOutputParameters
static ProfilerStatechartTransitionWithParameters toProfilerTransition(pid_t processId, uint64_t timestamp, const TransitionIceBase &transition)
void logStatechartTransition(const ProfilerStatechartTransition &transition) override
PeriodicTask< IceBufferedLoggingStrategy >::pointer_type publisherTask
void logProcessMemoryUsage(pid_t processId, u_int64_t timestamp, int memoryUsage) override
ProfilerProcessCpuUsageList profilerProcessCpuUsages
ProfilerStatechartTransitionWithParametersList profilerStatechartTransitionsWithParameters
IceBufferedLoggingStrategy(ProfilerListenerPrx profilerTopic)
ProfilerStatechartParametersList profilerStatechartInputParameters
ProfilerStatechartTransitionList profilerStatechartTransitions
ProfilerStatechartParametersList profilerStatechartLocalParameters
IceLoggingStrategy publishes incoming log method calls directly on IceLoggingStrategy::profilerListen...
IceLoggingStrategy(ProfilerListenerPrx profilerTopic)
void logStatechartTransitionWithParameters(pid_t processId, uint64_t timestamp, const TransitionIceBase &transition) override
void logStatechartOutputParameters(pid_t processId, uint64_t timestamp, const std::string &stateIdentifier, const armarx::StateParameterMap &outputParameterMap) override
void logStatechartInputParameters(pid_t processId, uint64_t timestamp, const std::string &stateIdentifier, const armarx::StateParameterMap &inputParameterMap) override
void logEvent(pid_t processId, uint64_t timestamp, const std::string &executableName, const std::string &timestampUnit, const std::string &eventName, const std::string &parentName, const std::string &functionName) override
void logProcessCpuUsage(pid_t processId, uint64_t timestamp, float cpuUsage) override
void logStatechartLocalParameters(pid_t processId, uint64_t timestamp, const std::string &stateIdentifier, const armarx::StateParameterMap &localParameterMap) override
void logStatechartTransition(const ProfilerStatechartTransition &transition) override
void logProcessMemoryUsage(pid_t processId, u_int64_t timestamp, int memoryUsage) override
std::shared_ptr< IceLoggingStrategy > IceLoggingStrategyPtr