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

Side by Side Diff: observatory_pub_packages/analyzer/src/generated/instrumentation.dart

Issue 816693004: Add observatory_pub_packages snapshot to third_party (Closed) Base URL: http://dart.googlecode.com/svn/third_party/
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
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 = new Instrumentat ionBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER();
46
47 /**
48 * An instrumentation logger that can be used when no other instrumentation lo gger has been
49 * configured. This logger will silently ignore all data and logging requests.
50 */
51 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_Instrume ntation_NULL_LOGGER();
52
53 /**
54 * The current instrumentation logger.
55 */
56 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER;
57
58 /**
59 * Create a builder that can collect the data associated with an operation.
60 *
61 * @param clazz the class performing the operation (not `null`)
62 * @return the builder that was created (not `null`)
63 */
64 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui lder(clazz.toString());
65
66 /**
67 * Create a builder that can collect the data associated with an operation.
68 *
69 * @param name the name used to uniquely identify the operation (not `null`)
70 * @return the builder that was created (not `null`)
71 */
72 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB uilder(name);
73
74 /**
75 * Get the currently active instrumentation logger
76 */
77 static InstrumentationLogger get logger => _CURRENT_LOGGER;
78
79 /**
80 * Return a builder that will silently ignore all data and logging requests.
81 *
82 * @return the builder (not `null`)
83 */
84 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER ;
85
86 /**
87 * Is this instrumentation system currently configured to drop instrumentation data provided to
88 * it?
89 *
90 * @return
91 */
92 static bool get isNullLogger => identical(_CURRENT_LOGGER, _NULL_LOGGER);
93
94 /**
95 * Set the logger that should receive instrumentation information to the given logger.
96 *
97 * @param logger the logger that should receive instrumentation information
98 */
99 static void set logger(InstrumentationLogger logger) {
100 _CURRENT_LOGGER = logger == null ? _NULL_LOGGER : logger;
101 }
102 }
103
104 /**
105 * The interface `InstrumentationBuilder` defines the behavior of objects used t o collect data
106 * about an operation that has occurred and record that data through an instrume ntation logger.
107 *
108 * For an example of using objects that implement this interface, see [Instrumen tation].
109 */
110 abstract class InstrumentationBuilder {
111 /**
112 * Append the given data to the data being collected by this builder. The info rmation is declared
113 * to potentially contain data that is either user identifiable or contains us er intellectual
114 * property (but is not guaranteed to contain either).
115 *
116 * @param name the name used to identify the data
117 * @param value the value of the data to be collected
118 * @return this builder
119 */
120 InstrumentationBuilder data(String name, bool value);
121
122 /**
123 * Append the given data to the data being collected by this builder. The info rmation is declared
124 * to potentially contain data that is either user identifiable or contains us er intellectual
125 * property (but is not guaranteed to contain either).
126 *
127 * @param name the name used to identify the data
128 * @param value the value of the data to be collected
129 * @return this builder
130 */
131 InstrumentationBuilder data2(String name, int value);
132
133 /**
134 * Append the given data to the data being collected by this builder. The info rmation is declared
135 * to potentially contain data that is either user identifiable or contains us er intellectual
136 * property (but is not guaranteed to contain either).
137 *
138 * @param name the name used to identify the data
139 * @param value the value of the data to be collected
140 * @return this builder
141 */
142 InstrumentationBuilder data3(String name, String value);
143
144 /**
145 * Append the given data to the data being collected by this builder. The info rmation is declared
146 * to potentially contain data that is either user identifiable or contains us er intellectual
147 * property (but is not guaranteed to contain either).
148 *
149 * @param name the name used to identify the data
150 * @param value the value of the data to be collected
151 * @return this builder
152 */
153 InstrumentationBuilder data4(String name, List<String> value);
154
155 /**
156 * Answer the [InstrumentationLevel] of this `InstrumentationBuilder`.
157 *
158 * @return one of [InstrumentationLevel#EVERYTHING], [InstrumentationLevel#MET RICS],
159 * [InstrumentationLevel#OFF]
160 */
161 InstrumentationLevel get instrumentationLevel;
162
163 /**
164 * Log the data that has been collected. The instrumentation builder should no t be used after this
165 * method is invoked. The behavior of any method defined on this interface tha t is used after this
166 * method is invoked is undefined.
167 */
168 void log();
169
170 /**
171 * Log the data that has been collected. The instrumentation builder should no t be used after this
172 * method is invoked. The behavior of any method defined on this interface tha t is used after this
173 * method is invoked is undefined.
174 *
175 * @param minTimeToLog if the total elapsed time is less than this, do not rec ord
176 */
177 void log2(int minTimeToLog);
178
179 /**
180 * Append the given metric to the data being collected by this builder. The in formation is
181 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
182 * user intellectual property).
183 *
184 * @param name the name used to identify the data
185 * @param value the value of the data to be collected
186 * @return this builder
187 */
188 InstrumentationBuilder metric(String name, bool value);
189
190 /**
191 * Append the given metric to the data being collected by this builder. The in formation is
192 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
193 * user intellectual property).
194 *
195 * @param name the name used to identify the data
196 * @param value the value of the data to be collected
197 * @return this builder
198 */
199 InstrumentationBuilder metric2(String name, int value);
200
201 /**
202 * Append the given metric to the data being collected by this builder. The in formation is
203 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
204 * user intellectual property).
205 *
206 * @param name the name used to identify the data
207 * @param value the value of the data to be collected
208 * @return this builder
209 */
210 InstrumentationBuilder metric3(String name, String value);
211
212 /**
213 * Append the given metric to the data being collected by this builder. The in formation is
214 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
215 * user intellectual property).
216 *
217 * @param name the name used to identify the data
218 * @param value the value of the data to be collected
219 * @return this builder
220 */
221 InstrumentationBuilder metric4(String name, List<String> value);
222
223 /**
224 * Append the given exception to the information being collected by this build er. The exception's
225 * class name is captured using [metric]. Other aspects of the exception
226 * may contain either user identifiable or contains user intellectual property (but is not
227 * guaranteed to contain either) and thus are captured using the various data methods such as
228 * [data].
229 *
230 * @param exception the exception (may be `null`)
231 */
232 InstrumentationBuilder record(Exception exception);
233 }
234
235 class InstrumentationBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER implem ents InstrumentationBuilder {
236 @override
237 InstrumentationBuilder data(String name, bool value) => this;
238
239 @override
240 InstrumentationBuilder data2(String name, int value) => this;
241
242 @override
243 InstrumentationBuilder data3(String name, String value) => this;
244
245 @override
246 InstrumentationBuilder data4(String name, List<String> value) => this;
247
248 @override
249 InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF;
250
251 @override
252 void log() {
253 }
254
255 @override
256 void log2(int minTimeToLong) {
257 }
258
259 @override
260 InstrumentationBuilder metric(String name, bool value) => this;
261
262 @override
263 InstrumentationBuilder metric2(String name, int value) => this;
264
265 @override
266 InstrumentationBuilder metric3(String name, String value) => this;
267
268 @override
269 InstrumentationBuilder metric4(String name, List<String> value) => this;
270
271 @override
272 InstrumentationBuilder record(Exception exception) => this;
273 }
274
275 /**
276 * The instrumentation recording level representing (1) recording [EVERYTHING] r ecording of
277 * all instrumentation data, (2) recording only [METRICS] information, or (3) re cording
278 * turned [OFF] in which case nothing is recorded.
279 */
280 class InstrumentationLevel extends Enum<InstrumentationLevel> {
281 /** Recording all instrumented information */
282 static const InstrumentationLevel EVERYTHING = const InstrumentationLevel('EVE RYTHING', 0);
283
284 /** Recording only metrics */
285 static const InstrumentationLevel METRICS = const InstrumentationLevel('METRIC S', 1);
286
287 /** Nothing recorded */
288 static const InstrumentationLevel OFF = const InstrumentationLevel('OFF', 2);
289
290 static const List<InstrumentationLevel> values = const [EVERYTHING, METRICS, O FF];
291
292 static InstrumentationLevel fromString(String str) {
293 if (str == "EVERYTHING") {
294 return InstrumentationLevel.EVERYTHING;
295 }
296 if (str == "METRICS") {
297 return InstrumentationLevel.METRICS;
298 }
299 if (str == "OFF") {
300 return InstrumentationLevel.OFF;
301 }
302 throw new IllegalArgumentException("Unrecognised InstrumentationLevel");
303 }
304
305 const InstrumentationLevel(String name, int ordinal) : super(name, ordinal);
306 }
307
308 /**
309 * The interface `InstrumentationLogger` defines the behavior of objects that ar e used to log
310 * instrumentation data.
311 *
312 * For an example of using objects that implement this interface, see [Instrumen tation].
313 */
314 abstract class InstrumentationLogger {
315 /**
316 * Create a builder that can collect the data associated with an operation ide ntified by the given
317 * name.
318 *
319 * @param name the name used to uniquely identify the operation
320 * @return the builder that was created
321 */
322 InstrumentationBuilder createBuilder(String name);
323 }
324
325 class InstrumentationLogger_Instrumentation_NULL_LOGGER implements Instrumentati onLogger {
326 @override
327 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS TRUMENTATION_BUILDER;
328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698