Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: pkg/analyzer/lib/src/generated/instrumentation.dart

Issue 784623004: Remove old instrumentation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information.
7
8 library engine.instrumentation;
9
10 import 'java_core.dart';
11
12 /**
13 * The class `Instrumentation` implements support for logging instrumentation in formation.
14 *
15 * Instrumentation information consists of information about specific operations . Those operations
16 * can range from user-facing operations, such as saving the changes to a file, to internal
17 * operations, such as tokenizing source code. The information to be logged is g athered by
18 * [InstrumentationBuilder], created by one of the static methods on
19 * this class such as [builder] or [builder].
20 *
21 * Note, however, that until an instrumentation logger is installed using the me thod
22 * [setLogger], all instrumentation data will be lost.
23 *
24 * <b>Example</b>
25 *
26 * To collect metrics about how long it took to save a file, you would write som ething like the
27 * following:
28 *
29 * <pre>
30 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas s());
31 * // save the file
32 * instrumentation.metric("chars", fileLength).log();
33 * </pre>
34 * The `Instrumentation.builder` method creates a new [InstrumentationBuilder]
35 * and records the time at which it was created. The
36 * [InstrumentationBuilder.metric] appends the information specified by the
37 * arguments and records the time at which the method is called so that the time to complete the
38 * save operation can be calculated. The `log` method tells the builder that all of the data
39 * has been collected and that the resulting information should be logged.
40 */
41 class Instrumentation {
42 /**
43 * A builder that will silently ignore all data and logging requests.
44 */
45 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER =
46 new InstrumentationBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER();
47
48 /**
49 * An instrumentation logger that can be used when no other instrumentation lo gger has been
50 * configured. This logger will silently ignore all data and logging requests.
51 */
52 static InstrumentationLogger _NULL_LOGGER =
53 new InstrumentationLogger_Instrumentation_NULL_LOGGER();
54
55 /**
56 * The current instrumentation logger.
57 */
58 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER;
59
60 /**
61 * Is this instrumentation system currently configured to drop instrumentation data provided to
62 * it?
63 *
64 * @return
65 */
66 static bool get isNullLogger => identical(_CURRENT_LOGGER, _NULL_LOGGER);
67
68 /**
69 * Get the currently active instrumentation logger
70 */
71 static InstrumentationLogger get logger => _CURRENT_LOGGER;
72
73 /**
74 * Set the logger that should receive instrumentation information to the given logger.
75 *
76 * @param logger the logger that should receive instrumentation information
77 */
78 static void set logger(InstrumentationLogger logger) {
79 _CURRENT_LOGGER = logger == null ? _NULL_LOGGER : logger;
80 }
81
82 /**
83 * Return a builder that will silently ignore all data and logging requests.
84 *
85 * @return the builder (not `null`)
86 */
87 static InstrumentationBuilder get nullBuilder =>
88 _NULL_INSTRUMENTATION_BUILDER;
89
90 /**
91 * Create a builder that can collect the data associated with an operation.
92 *
93 * @param clazz the class performing the operation (not `null`)
94 * @return the builder that was created (not `null`)
95 */
96 static InstrumentationBuilder builder(Type clazz) =>
97 _CURRENT_LOGGER.createBuilder(clazz.toString());
98
99 /**
100 * Create a builder that can collect the data associated with an operation.
101 *
102 * @param name the name used to uniquely identify the operation (not `null`)
103 * @return the builder that was created (not `null`)
104 */
105 static InstrumentationBuilder builder2(String name) =>
106 _CURRENT_LOGGER.createBuilder(name);
107 }
108
109 /**
110 * The interface `InstrumentationBuilder` defines the behavior of objects used t o collect data
111 * about an operation that has occurred and record that data through an instrume ntation logger.
112 *
113 * For an example of using objects that implement this interface, see [Instrumen tation].
114 */
115 abstract class InstrumentationBuilder {
116 /**
117 * Answer the [InstrumentationLevel] of this `InstrumentationBuilder`.
118 *
119 * @return one of [InstrumentationLevel.EVERYTHING], [InstrumentationLevel.MET RICS],
120 * [InstrumentationLevel.OFF]
121 */
122 InstrumentationLevel get instrumentationLevel;
123
124 /**
125 * Append the given data to the data being collected by this builder. The info rmation is declared
126 * to potentially contain data that is either user identifiable or contains us er intellectual
127 * property (but is not guaranteed to contain either).
128 *
129 * @param name the name used to identify the data
130 * @param value the value of the data to be collected
131 * @return this builder
132 */
133 InstrumentationBuilder data(String name, bool value);
134
135 /**
136 * Append the given data to the data being collected by this builder. The info rmation is declared
137 * to potentially contain data that is either user identifiable or contains us er intellectual
138 * property (but is not guaranteed to contain either).
139 *
140 * @param name the name used to identify the data
141 * @param value the value of the data to be collected
142 * @return this builder
143 */
144 InstrumentationBuilder data2(String name, int value);
145
146 /**
147 * Append the given data to the data being collected by this builder. The info rmation is declared
148 * to potentially contain data that is either user identifiable or contains us er intellectual
149 * property (but is not guaranteed to contain either).
150 *
151 * @param name the name used to identify the data
152 * @param value the value of the data to be collected
153 * @return this builder
154 */
155 InstrumentationBuilder data3(String name, String value);
156
157 /**
158 * Append the given data to the data being collected by this builder. The info rmation is declared
159 * to potentially contain data that is either user identifiable or contains us er intellectual
160 * property (but is not guaranteed to contain either).
161 *
162 * @param name the name used to identify the data
163 * @param value the value of the data to be collected
164 * @return this builder
165 */
166 InstrumentationBuilder data4(String name, List<String> value);
167
168 /**
169 * Log the data that has been collected. The instrumentation builder should no t be used after this
170 * method is invoked. The behavior of any method defined on this interface tha t is used after this
171 * method is invoked is undefined.
172 */
173 void log();
174
175 /**
176 * Log the data that has been collected. The instrumentation builder should no t be used after this
177 * method is invoked. The behavior of any method defined on this interface tha t is used after this
178 * method is invoked is undefined.
179 *
180 * @param minTimeToLog if the total elapsed time is less than this, do not rec ord
181 */
182 void log2(int minTimeToLog);
183
184 /**
185 * Append the given metric to the data being collected by this builder. The in formation is
186 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
187 * user intellectual property).
188 *
189 * @param name the name used to identify the data
190 * @param value the value of the data to be collected
191 * @return this builder
192 */
193 InstrumentationBuilder metric(String name, bool value);
194
195 /**
196 * Append the given metric to the data being collected by this builder. The in formation is
197 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
198 * user intellectual property).
199 *
200 * @param name the name used to identify the data
201 * @param value the value of the data to be collected
202 * @return this builder
203 */
204 InstrumentationBuilder metric2(String name, int value);
205
206 /**
207 * Append the given metric to the data being collected by this builder. The in formation is
208 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
209 * user intellectual property).
210 *
211 * @param name the name used to identify the data
212 * @param value the value of the data to be collected
213 * @return this builder
214 */
215 InstrumentationBuilder metric3(String name, String value);
216
217 /**
218 * Append the given metric to the data being collected by this builder. The in formation is
219 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
220 * user intellectual property).
221 *
222 * @param name the name used to identify the data
223 * @param value the value of the data to be collected
224 * @return this builder
225 */
226 InstrumentationBuilder metric4(String name, List<String> value);
227
228 /**
229 * Append the given exception to the information being collected by this build er. The exception's
230 * class name is captured using [metric]. Other aspects of the exception
231 * may contain either user identifiable or contains user intellectual property (but is not
232 * guaranteed to contain either) and thus are captured using the various data methods such as
233 * [data].
234 *
235 * @param exception the exception (may be `null`)
236 */
237 InstrumentationBuilder record(Exception exception);
238 }
239
240 class InstrumentationBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER
241 implements InstrumentationBuilder {
242 @override
243 InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF;
244
245 @override
246 InstrumentationBuilder data(String name, bool value) => this;
247
248 @override
249 InstrumentationBuilder data2(String name, int value) => this;
250
251 @override
252 InstrumentationBuilder data3(String name, String value) => this;
253
254 @override
255 InstrumentationBuilder data4(String name, List<String> value) => this;
256
257 @override
258 void log() {
259 }
260
261 @override
262 void log2(int minTimeToLong) {
263 }
264
265 @override
266 InstrumentationBuilder metric(String name, bool value) => this;
267
268 @override
269 InstrumentationBuilder metric2(String name, int value) => this;
270
271 @override
272 InstrumentationBuilder metric3(String name, String value) => this;
273
274 @override
275 InstrumentationBuilder metric4(String name, List<String> value) => this;
276
277 @override
278 InstrumentationBuilder record(Exception exception) => this;
279 }
280
281 /**
282 * The instrumentation recording level representing (1) recording [EVERYTHING] r ecording of
283 * all instrumentation data, (2) recording only [METRICS] information, or (3) re cording
284 * turned [OFF] in which case nothing is recorded.
285 */
286 class InstrumentationLevel extends Enum<InstrumentationLevel> {
287 /** Recording all instrumented information */
288 static const InstrumentationLevel EVERYTHING =
289 const InstrumentationLevel('EVERYTHING', 0);
290
291 /** Recording only metrics */
292 static const InstrumentationLevel METRICS =
293 const InstrumentationLevel('METRICS', 1);
294
295 /** Nothing recorded */
296 static const InstrumentationLevel OFF = const InstrumentationLevel('OFF', 2);
297
298 static const List<InstrumentationLevel> values = const [
299 EVERYTHING,
300 METRICS,
301 OFF];
302
303 const InstrumentationLevel(String name, int ordinal) : super(name, ordinal);
304
305 static InstrumentationLevel fromString(String str) {
306 if (str == "EVERYTHING") {
307 return InstrumentationLevel.EVERYTHING;
308 }
309 if (str == "METRICS") {
310 return InstrumentationLevel.METRICS;
311 }
312 if (str == "OFF") {
313 return InstrumentationLevel.OFF;
314 }
315 throw new IllegalArgumentException("Unrecognised InstrumentationLevel");
316 }
317 }
318
319 /**
320 * The interface `InstrumentationLogger` defines the behavior of objects that ar e used to log
321 * instrumentation data.
322 *
323 * For an example of using objects that implement this interface, see [Instrumen tation].
324 */
325 abstract class InstrumentationLogger {
326 /**
327 * Create a builder that can collect the data associated with an operation ide ntified by the given
328 * name.
329 *
330 * @param name the name used to uniquely identify the operation
331 * @return the builder that was created
332 */
333 InstrumentationBuilder createBuilder(String name);
334 }
335
336 class InstrumentationLogger_Instrumentation_NULL_LOGGER implements
337 InstrumentationLogger {
338 @override
339 InstrumentationBuilder createBuilder(String name) =>
340 Instrumentation._NULL_INSTRUMENTATION_BUILDER;
341 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698