Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-generic-events into lp:ubuntu-ui-toolkit/staging
- ubuntu-metrics-generic-events
- Merge into staging
Status: | Superseded |
---|---|
Proposed branch: | lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-generic-events |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Prerequisite: | lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-lttng |
Diff against target: |
292 lines (+146/-4) 9 files modified
src/Ubuntu/UbuntuMetrics/applicationmonitor.cpp (+40/-0) src/Ubuntu/UbuntuMetrics/applicationmonitor.h (+25/-1) src/Ubuntu/UbuntuMetrics/events.h (+21/-1) src/Ubuntu/UbuntuMetrics/logger.cpp (+28/-1) src/Ubuntu/UbuntuMetrics/lttng/lttng.c (+7/-1) src/Ubuntu/UbuntuMetrics/lttng/lttng_p.h (+10/-0) src/Ubuntu/UbuntuMetrics/lttng/tracepoints_p.h (+11/-0) src/Ubuntu/UbuntuToolkit/ubuntutoolkitmodule.cpp (+2/-0) ubuntu-ui-toolkit-launcher/launcher.cpp (+2/-0) |
To merge this branch: | bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-generic-events |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
ubuntu-sdk-build-bot | continuous-integration | Needs Fixing | |
Ubuntu SDK team | Pending | ||
Review via email: mp+301306@code.launchpad.net |
Commit message
Added support for logging generic events.
Made use of it to log predefined ApplicationMonitor events. Predefined events only define UserInterfaceReady for now, as it's needed to track start-up time.
Description of the change
Added support for logging generic events.
Made use of it to log predefined ApplicationMonitor events. Predefined events only define UserInterfaceReady for now, as it's needed to track start-up time.
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
- 2049. By Loïc Molinari
-
Removed remaining testing code.
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2048
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2048
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2048
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2048
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2049
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2049
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2049
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2049
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2049
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
- 2050. By Loïc Molinari
-
Merged prerequiste branch lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-lttng.
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2050
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2050
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2050
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2050
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2050
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
- 2051. By Loïc Molinari
-
Merged prerequiste branch lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-lttng.
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2051
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2051
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2051
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2051
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2051
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
- 2052. By Loïc Molinari
-
Merged prerequiste branch lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-metrics-lttng.
- 2053. By Loïc Molinari
-
Added generic filter to launcher and toolkit module.
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2053
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2053
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
PASSED: Continuous integration, rev:2053
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2053
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : | # |
FAILED: Continuous integration, rev:2053
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Unmerged revisions
Preview Diff
1 | === modified file 'src/Ubuntu/UbuntuMetrics/applicationmonitor.cpp' |
2 | --- src/Ubuntu/UbuntuMetrics/applicationmonitor.cpp 2016-08-06 00:55:55 +0000 |
3 | +++ src/Ubuntu/UbuntuMetrics/applicationmonitor.cpp 2016-08-06 00:55:55 +0000 |
4 | @@ -549,6 +549,46 @@ |
5 | } |
6 | } |
7 | |
8 | +quint32 UMApplicationMonitor::registerGenericEvent() |
9 | +{ |
10 | + static quint32 id = 0; // 0 is reserved for UMApplicationMonitor events. |
11 | + return ++id; |
12 | +} |
13 | + |
14 | +bool UMApplicationMonitor::logGenericEvent(quint32 id, const char* string, quint32 size) |
15 | +{ |
16 | + Q_D(UMApplicationMonitor); |
17 | + |
18 | + if ((d->m_flags & UMApplicationMonitorPrivate::Logging) && (d->m_flags & GenericEvent)) { |
19 | + DASSERT(d->m_loggingThread); |
20 | + UMEvent event; |
21 | + event.type = UMEvent::Generic; |
22 | + event.timeStamp = UMEventUtils::timeStamp(); |
23 | + event.generic.id = id; |
24 | + // We don't bother fixing up non null-terminated string, just potential |
25 | + // overflows. |
26 | + event.generic.stringSize = qMin(size, UMGenericEvent::maxStringSize); |
27 | + memcpy(event.generic.string, string, event.generic.stringSize); |
28 | + d->m_loggingThread->push(&event); |
29 | + return true; |
30 | + } else { |
31 | + return false; |
32 | + } |
33 | +} |
34 | + |
35 | +bool UMApplicationMonitor::logEvent(Event event) |
36 | +{ |
37 | + switch (event) { |
38 | + case UserInterfaceReady: { |
39 | + return logGenericEvent(0, "UserInterfaceReady", sizeof("UserInterfaceReady")); |
40 | + } |
41 | + default: { |
42 | + DNOT_REACHED(); |
43 | + return false; |
44 | + } |
45 | + }; |
46 | +} |
47 | + |
48 | void UMApplicationMonitor::setUpdateInterval(UMEvent::Type type, int interval) |
49 | { |
50 | Q_D(UMApplicationMonitor); |
51 | |
52 | === modified file 'src/Ubuntu/UbuntuMetrics/applicationmonitor.h' |
53 | --- src/Ubuntu/UbuntuMetrics/applicationmonitor.h 2016-08-06 00:55:55 +0000 |
54 | +++ src/Ubuntu/UbuntuMetrics/applicationmonitor.h 2016-08-06 00:55:55 +0000 |
55 | @@ -40,11 +40,20 @@ |
56 | WindowEvent = (1 << 1), |
57 | // Allow frame events logging. |
58 | FrameEvent = (1 << 2), |
59 | + // Allow generic events logging. |
60 | + GenericEvent = (1 << 3), |
61 | // Allow all events logging. |
62 | - AllEvents = (ProcessEvent | WindowEvent | FrameEvent) |
63 | + AllEvents = (ProcessEvent | WindowEvent | FrameEvent | GenericEvent) |
64 | }; |
65 | Q_DECLARE_FLAGS(LoggingFilters, LoggingFilter) |
66 | |
67 | + enum Event { |
68 | + // Application defined event indicating that the initialisation is done |
69 | + // and the UI ready. It can be used by tools to measure the time needed |
70 | + // to start up an application. |
71 | + UserInterfaceReady = 0 |
72 | + }; |
73 | + |
74 | // Get the unique UMApplicationMonitor instance. A QGuiApplication instance |
75 | // must be running. |
76 | static UMApplicationMonitor* instance() { return self ? self : new UMApplicationMonitor; } |
77 | @@ -67,6 +76,21 @@ |
78 | bool removeLogger(UMLogger* logger, bool free = true); |
79 | void clearLoggers(bool free = true); |
80 | |
81 | + // Generic event system allowing to log application specific |
82 | + // events. registerGenericEvent() returns a unique integer id to be used as |
83 | + // first argument to logGenericEvent(). logGenericEvent() logs a generic |
84 | + // event with a dedicated id, a null-terminated string describing the event |
85 | + // and the string size with the null-terminating character. The maximum |
86 | + // string size (with the null-terminating character) is defined in |
87 | + // UMGenericEvent::maxStringSize. Does not log and returns false if logging |
88 | + // is disabled or if the logging filter does not contain GenericEvent. |
89 | + quint32 registerGenericEvent(); |
90 | + bool logGenericEvent(quint32 id, const char* string, quint32 size); |
91 | + |
92 | + // Log events predefined by the application monitor. Relies on the generic |
93 | + // event system. |
94 | + bool logEvent(Event event); |
95 | + |
96 | // Set the time in milliseconds between two updates of events of a given |
97 | // type. -1 to disable updates. Only UMEvent::Process is accepted so far as |
98 | // event type, default value is 1000. Note that when the overlay is enabled, |
99 | |
100 | === modified file 'src/Ubuntu/UbuntuMetrics/events.h' |
101 | --- src/Ubuntu/UbuntuMetrics/events.h 2016-08-06 00:55:55 +0000 |
102 | +++ src/Ubuntu/UbuntuMetrics/events.h 2016-08-06 00:55:55 +0000 |
103 | @@ -99,9 +99,28 @@ |
104 | }; |
105 | Q_STATIC_ASSERT(sizeof(UMFrameEvent) == 112); |
106 | |
107 | +struct UBUNTU_METRICS_EXPORT UMGenericEvent |
108 | +{ |
109 | + static const quint32 maxStringSize = 64; |
110 | + |
111 | + // Id retrieved from UMApplicationMonitor::registerGenericEvent(). |
112 | + quint32 id; |
113 | + |
114 | + // Size of the string (including the null-terminating char). |
115 | + quint32 stringSize; |
116 | + |
117 | + // Null-terminated string describing the generic event. |
118 | + char string[maxStringSize]; |
119 | + |
120 | + // The whole struct must take 112 bytes to allow future additions and best |
121 | + // memory alignment, don't forget to update when adding new metrics. |
122 | + quint8 __reserved[/*72 bytes taken,*/ 40 /*bytes free*/]; |
123 | +}; |
124 | +Q_STATIC_ASSERT(sizeof(UMGenericEvent) == 112); |
125 | + |
126 | struct UBUNTU_METRICS_EXPORT UMEvent |
127 | { |
128 | - enum Type { Process = 0, Window = 1, Frame = 2, TypeCount = 3 }; |
129 | + enum Type { Process = 0, Window = 1, Frame = 2, Generic = 3, TypeCount = 4 }; |
130 | |
131 | // Event type. |
132 | Type type; |
133 | @@ -113,6 +132,7 @@ |
134 | UMProcessEvent process; |
135 | UMWindowEvent window; |
136 | UMFrameEvent frame; |
137 | + UMGenericEvent generic; |
138 | }; |
139 | }; |
140 | Q_STATIC_ASSERT(sizeof(UMEvent) == 128); |
141 | |
142 | === modified file 'src/Ubuntu/UbuntuMetrics/logger.cpp' |
143 | --- src/Ubuntu/UbuntuMetrics/logger.cpp 2016-08-06 00:55:55 +0000 |
144 | +++ src/Ubuntu/UbuntuMetrics/logger.cpp 2016-08-06 00:55:55 +0000 |
145 | @@ -175,7 +175,7 @@ |
146 | << event.window.height << '\n' << flush; |
147 | } else { |
148 | const char* const stateString[] = { "Hidden", "Shown", "Resized" }; |
149 | - Q_STATIC_ASSERT(ARRAY_SIZE(stateString) == UMEvent::TypeCount); |
150 | + Q_STATIC_ASSERT(ARRAY_SIZE(stateString) == UMWindowEvent::StateCount); |
151 | m_textStream |
152 | << (m_flags & Colored ? "\033[35mW\033[00m " : "W ") |
153 | << dim << timeString << reset << ' ' |
154 | @@ -187,6 +187,24 @@ |
155 | break; |
156 | } |
157 | |
158 | + case UMEvent::Generic: { |
159 | + if (m_flags & Parsable) { |
160 | + m_textStream |
161 | + << "G " |
162 | + << event.timeStamp << ' ' |
163 | + << event.generic.id << ' ' |
164 | + << event.generic.string << '\n' << flush; |
165 | + } else { |
166 | + m_textStream |
167 | + << (m_flags & Colored ? "\033[32mG\033[00m " : "G ") |
168 | + << dim << timeString << reset << ' ' |
169 | + << "Id" << dimColon << event.generic.id << ' ' |
170 | + << "String" << dimColon << '"' << event.generic.string << '"' |
171 | + << '\n' << flush; |
172 | + } |
173 | + break; |
174 | + } |
175 | + |
176 | default: |
177 | DNOT_REACHED(); |
178 | break; |
179 | @@ -284,6 +302,15 @@ |
180 | break; |
181 | } |
182 | |
183 | + case UMEvent::Generic: { |
184 | + UMLTTNGGenericEvent genericEvent; |
185 | + genericEvent.id = event.generic.id; |
186 | + DASSERT(event.generic.stringSize < UMGenericEvent::maxStringSize); |
187 | + memcpy(genericEvent.string, event.generic.string, event.generic.stringSize); |
188 | + m_plugin->logGenericEvent(&genericEvent); |
189 | + break; |
190 | + } |
191 | + |
192 | default: |
193 | DNOT_REACHED(); |
194 | break; |
195 | |
196 | === modified file 'src/Ubuntu/UbuntuMetrics/lttng/lttng.c' |
197 | --- src/Ubuntu/UbuntuMetrics/lttng/lttng.c 2016-08-06 00:55:55 +0000 |
198 | +++ src/Ubuntu/UbuntuMetrics/lttng/lttng.c 2016-08-06 00:55:55 +0000 |
199 | @@ -33,8 +33,14 @@ |
200 | tracepoint(UbuntuMetrics, window, event); |
201 | } |
202 | |
203 | +static void logGenericEvent(UMLTTNGGenericEvent* event) |
204 | +{ |
205 | + tracepoint(UbuntuMetrics, generic, event); |
206 | +} |
207 | + |
208 | const struct UMLTTNGPlugin umLttngPlugin = { |
209 | &logProcessEvent, |
210 | &logFrameEvent, |
211 | - &logWindowEvent |
212 | + &logWindowEvent, |
213 | + &logGenericEvent, |
214 | }; |
215 | |
216 | === modified file 'src/Ubuntu/UbuntuMetrics/lttng/lttng_p.h' |
217 | --- src/Ubuntu/UbuntuMetrics/lttng/lttng_p.h 2016-08-06 00:55:55 +0000 |
218 | +++ src/Ubuntu/UbuntuMetrics/lttng/lttng_p.h 2016-08-06 00:55:55 +0000 |
219 | @@ -24,11 +24,13 @@ |
220 | typedef struct _UMLTTNGProcessEvent UMLTTNGProcessEvent; |
221 | typedef struct _UMLTTNGFrameEvent UMLTTNGFrameEvent; |
222 | typedef struct _UMLTTNGWindowEvent UMLTTNGWindowEvent; |
223 | +typedef struct _UMLTTNGGenericEvent UMLTTNGGenericEvent; |
224 | |
225 | struct UMLTTNGPlugin { |
226 | void (*logProcessEvent)(UMLTTNGProcessEvent*); |
227 | void (*logFrameEvent)(UMLTTNGFrameEvent*); |
228 | void (*logWindowEvent)(UMLTTNGWindowEvent*); |
229 | + void (*logGenericEvent)(UMLTTNGGenericEvent*); |
230 | }; |
231 | |
232 | struct _UMLTTNGProcessEvent { |
233 | @@ -55,4 +57,12 @@ |
234 | uint16_t height; |
235 | }; |
236 | |
237 | +struct _UMLTTNGGenericEvent { |
238 | + uint32_t id; |
239 | + // Keep the size in sync with UMGenericEvent::maxStringSize. Unfortunately, |
240 | + // a static assert is not possible here since it's C and we can't include |
241 | + // the events.h C++ header. |
242 | + char string[64]; |
243 | +}; |
244 | + |
245 | #endif // LTTNG_P_H |
246 | |
247 | === modified file 'src/Ubuntu/UbuntuMetrics/lttng/tracepoints_p.h' |
248 | --- src/Ubuntu/UbuntuMetrics/lttng/tracepoints_p.h 2016-08-06 00:55:55 +0000 |
249 | +++ src/Ubuntu/UbuntuMetrics/lttng/tracepoints_p.h 2016-08-06 00:55:55 +0000 |
250 | @@ -68,5 +68,16 @@ |
251 | ) |
252 | ) |
253 | |
254 | +TRACEPOINT_EVENT( |
255 | + UbuntuMetrics, generic, |
256 | + TP_ARGS( |
257 | + UMLTTNGGenericEvent*, genericEvent |
258 | + ), |
259 | + TP_FIELDS( |
260 | + ctf_integer(uint32_t, id, genericEvent->id) |
261 | + ctf_string(string, genericEvent->string) |
262 | + ) |
263 | +) |
264 | + |
265 | #endif // TRACEPOINTS_P_H |
266 | #include <lttng/tracepoint-event.h> |
267 | |
268 | === modified file 'src/Ubuntu/UbuntuToolkit/ubuntutoolkitmodule.cpp' |
269 | --- src/Ubuntu/UbuntuToolkit/ubuntutoolkitmodule.cpp 2016-08-06 00:55:55 +0000 |
270 | +++ src/Ubuntu/UbuntuToolkit/ubuntutoolkitmodule.cpp 2016-08-06 00:55:55 +0000 |
271 | @@ -288,6 +288,8 @@ |
272 | filter |= UMApplicationMonitor::ProcessEvent; |
273 | } else if (filterList[i] == "frame") { |
274 | filter |= UMApplicationMonitor::FrameEvent; |
275 | + } else if (filterList[i] == "generic") { |
276 | + filter |= UMApplicationMonitor::GenericEvent; |
277 | } |
278 | } |
279 | applicationMonitor->setLoggingFilter(filter); |
280 | |
281 | === modified file 'ubuntu-ui-toolkit-launcher/launcher.cpp' |
282 | --- ubuntu-ui-toolkit-launcher/launcher.cpp 2016-08-06 00:55:55 +0000 |
283 | +++ ubuntu-ui-toolkit-launcher/launcher.cpp 2016-08-06 00:55:55 +0000 |
284 | @@ -228,6 +228,8 @@ |
285 | filter |= UMApplicationMonitor::ProcessEvent; |
286 | } else if (filterList[i] == "frame") { |
287 | filter |= UMApplicationMonitor::FrameEvent; |
288 | + } else if (filterList[i] == "generic") { |
289 | + filter |= UMApplicationMonitor::GenericEvent; |
290 | } |
291 | } |
292 | applicationMonitor->setLoggingFilter(filter); |
FAILED: Continuous integration, rev:2048 /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- devel/904/ /jenkins. ubuntu. com/ubuntu- sdk/job/ generic- update- mp/4705/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/ubuntu- sdk/job/ ubuntu- ui-toolkit- ci-amd64- devel/904/ rebuild
https:/