OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 library engine.instrumentation; | 3 library engine.instrumentation; |
4 import 'java_core.dart'; | 4 import 'java_core.dart'; |
5 /** | 5 /** |
6 * The class `Instrumentation` implements support for logging instrumentation in
formation. | 6 * The class `Instrumentation` implements support for logging instrumentation in
formation. |
7 * | 7 * |
8 * Instrumentation information consists of information about specific operations
. Those operations | 8 * Instrumentation information consists of information about specific operations
. Those operations |
9 * can range from user-facing operations, such as saving the changes to a file,
to internal | 9 * can range from user-facing operations, such as saving the changes to a file,
to internal |
10 * operations, such as tokenizing source code. The information to be logged is g
athered by[InstrumentationBuilder instrumentation builder], created by one of th
e static methods on | 10 * operations, such as tokenizing source code. The information to be logged is g
athered by |
| 11 * [InstrumentationBuilder], created by one of the static methods on |
11 * this class such as [builder] or [builder]. | 12 * this class such as [builder] or [builder]. |
12 * | 13 * |
13 * Note, however, that until an instrumentation logger is installed using the me
thod[setLogger], all instrumentation data will be lost. | 14 * Note, however, that until an instrumentation logger is installed using the me
thod |
| 15 * [setLogger], all instrumentation data will be lost. |
14 * | 16 * |
15 * <b>Example</b> | 17 * <b>Example</b> |
16 * | 18 * |
17 * To collect metrics about how long it took to save a file, you would write som
ething like the | 19 * To collect metrics about how long it took to save a file, you would write som
ething like the |
18 * following: | 20 * following: |
| 21 * |
19 * <pre> | 22 * <pre> |
20 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas
s()); | 23 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas
s()); |
21 * // save the file | 24 * // save the file |
22 * instrumentation.metric("chars", fileLength).log(); | 25 * instrumentation.metric("chars", fileLength).log(); |
23 * </pre> | 26 * </pre> |
24 * The `Instrumentation.builder` method creates a new [InstrumentationBuilderins
trumentation builder] and records the time at which it was created. The[Instrume
ntationBuilder#metric] appends the information specified by the | 27 * The `Instrumentation.builder` method creates a new [InstrumentationBuilder |
| 28 ] and records the time at which it was created. The |
| 29 * [InstrumentationBuilder#metric] appends the information specified by the |
25 * arguments and records the time at which the method is called so that the time
to complete the | 30 * arguments and records the time at which the method is called so that the time
to complete the |
26 * save operation can be calculated. The `log` method tells the builder that all
of the data | 31 * save operation can be calculated. The `log` method tells the builder that all
of the data |
27 * has been collected and that the resulting information should be logged. | 32 * has been collected and that the resulting information should be logged. |
| 33 * |
28 * @coverage dart.engine.utilities | 34 * @coverage dart.engine.utilities |
29 */ | 35 */ |
30 class Instrumentation { | 36 class Instrumentation { |
31 | 37 |
32 /** | 38 /** |
33 * A builder that will silently ignore all data and logging requests. | 39 * A builder that will silently ignore all data and logging requests. |
34 */ | 40 */ |
35 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new Instrumentat
ionBuilder_12(); | 41 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new Instrumentat
ionBuilder_13(); |
36 | 42 |
37 /** | 43 /** |
38 * An instrumentation logger that can be used when no other instrumentation lo
gger has been | 44 * An instrumentation logger that can be used when no other instrumentation lo
gger has been |
39 * configured. This logger will silently ignore all data and logging requests. | 45 * configured. This logger will silently ignore all data and logging requests. |
40 */ | 46 */ |
41 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_13(); | 47 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_14(); |
42 | 48 |
43 /** | 49 /** |
44 * The current instrumentation logger. | 50 * The current instrumentation logger. |
45 */ | 51 */ |
46 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER; | 52 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER; |
47 | 53 |
48 /** | 54 /** |
49 * Create a builder that can collect the data associated with an operation. | 55 * Create a builder that can collect the data associated with an operation. |
| 56 * |
50 * @param clazz the class performing the operation (not `null`) | 57 * @param clazz the class performing the operation (not `null`) |
51 * @return the builder that was created (not `null`) | 58 * @return the builder that was created (not `null`) |
52 */ | 59 */ |
53 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui
lder(clazz.toString()); | 60 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui
lder(clazz.toString()); |
54 | 61 |
55 /** | 62 /** |
56 * Create a builder that can collect the data associated with an operation. | 63 * Create a builder that can collect the data associated with an operation. |
| 64 * |
57 * @param name the name used to uniquely identify the operation (not `null`) | 65 * @param name the name used to uniquely identify the operation (not `null`) |
58 * @return the builder that was created (not `null`) | 66 * @return the builder that was created (not `null`) |
59 */ | 67 */ |
60 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB
uilder(name); | 68 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB
uilder(name); |
61 | 69 |
62 /** | 70 /** |
63 * Get the currently active instrumentation logger | 71 * Get the currently active instrumentation logger |
64 */ | 72 */ |
65 static InstrumentationLogger get logger => _CURRENT_LOGGER; | 73 static InstrumentationLogger get logger => _CURRENT_LOGGER; |
66 | 74 |
67 /** | 75 /** |
68 * Return a builder that will silently ignore all data and logging requests. | 76 * Return a builder that will silently ignore all data and logging requests. |
| 77 * |
69 * @return the builder (not `null`) | 78 * @return the builder (not `null`) |
70 */ | 79 */ |
71 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER
; | 80 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER
; |
72 | 81 |
73 /** | 82 /** |
74 * Is this instrumentation system currently configured to drop instrumentation
data provided to | 83 * Is this instrumentation system currently configured to drop instrumentation
data provided to |
75 * it? | 84 * it? |
| 85 * |
76 * @return | 86 * @return |
77 */ | 87 */ |
78 static bool get isNullLogger => identical(_CURRENT_LOGGER, _NULL_LOGGER); | 88 static bool get isNullLogger => identical(_CURRENT_LOGGER, _NULL_LOGGER); |
79 | 89 |
80 /** | 90 /** |
81 * Set the logger that should receive instrumentation information to the given
logger. | 91 * Set the logger that should receive instrumentation information to the given
logger. |
| 92 * |
82 * @param logger the logger that should receive instrumentation information | 93 * @param logger the logger that should receive instrumentation information |
83 */ | 94 */ |
84 static void set logger(InstrumentationLogger logger2) { | 95 static void set logger(InstrumentationLogger logger2) { |
85 _CURRENT_LOGGER = logger2 == null ? _NULL_LOGGER : logger2; | 96 _CURRENT_LOGGER = logger2 == null ? _NULL_LOGGER : logger2; |
86 } | 97 } |
87 } | 98 } |
88 class InstrumentationBuilder_12 implements InstrumentationBuilder { | 99 class InstrumentationBuilder_13 implements InstrumentationBuilder { |
89 InstrumentationBuilder data(String name, bool value) => this; | 100 InstrumentationBuilder data(String name, bool value) => this; |
90 InstrumentationBuilder data2(String name, int value) => this; | 101 InstrumentationBuilder data2(String name, int value) => this; |
91 InstrumentationBuilder data3(String name, String value) => this; | 102 InstrumentationBuilder data3(String name, String value) => this; |
92 InstrumentationBuilder data4(String name, List<String> value) => this; | 103 InstrumentationBuilder data4(String name, List<String> value) => this; |
93 InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF; | 104 InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF; |
94 void log() { | 105 void log() { |
95 } | 106 } |
96 InstrumentationBuilder metric(String name, bool value) => this; | 107 InstrumentationBuilder metric(String name, bool value) => this; |
97 InstrumentationBuilder metric2(String name, int value) => this; | 108 InstrumentationBuilder metric2(String name, int value) => this; |
98 InstrumentationBuilder metric3(String name, String value) => this; | 109 InstrumentationBuilder metric3(String name, String value) => this; |
99 InstrumentationBuilder metric4(String name, List<String> value) => this; | 110 InstrumentationBuilder metric4(String name, List<String> value) => this; |
100 InstrumentationBuilder record(Exception exception) => this; | 111 InstrumentationBuilder record(Exception exception) => this; |
101 } | 112 } |
102 class InstrumentationLogger_13 implements InstrumentationLogger { | 113 class InstrumentationLogger_14 implements InstrumentationLogger { |
103 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS
TRUMENTATION_BUILDER; | 114 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS
TRUMENTATION_BUILDER; |
104 } | 115 } |
105 /** | 116 /** |
106 * The interface `InstrumentationBuilder` defines the behavior of objects used t
o collect data | 117 * The interface `InstrumentationBuilder` defines the behavior of objects used t
o collect data |
107 * about an operation that has occurred and record that data through an instrume
ntation logger. | 118 * about an operation that has occurred and record that data through an instrume
ntation logger. |
108 * | 119 * |
109 * For an example of using objects that implement this interface, see [Instrumen
tation]. | 120 * For an example of using objects that implement this interface, see [Instrumen
tation]. |
| 121 * |
110 * @coverage dart.engine.utilities | 122 * @coverage dart.engine.utilities |
111 */ | 123 */ |
112 abstract class InstrumentationBuilder { | 124 abstract class InstrumentationBuilder { |
113 | 125 |
114 /** | 126 /** |
115 * Append the given data to the data being collected by this builder. The info
rmation is declared | 127 * Append the given data to the data being collected by this builder. The info
rmation is declared |
116 * to potentially contain data that is either user identifiable or contains us
er intellectual | 128 * to potentially contain data that is either user identifiable or contains us
er intellectual |
117 * property (but is not guaranteed to contain either). | 129 * property (but is not guaranteed to contain either). |
| 130 * |
118 * @param name the name used to identify the data | 131 * @param name the name used to identify the data |
119 * @param value the value of the data to be collected | 132 * @param value the value of the data to be collected |
120 * @return this builder | 133 * @return this builder |
121 */ | 134 */ |
122 InstrumentationBuilder data(String name, bool value); | 135 InstrumentationBuilder data(String name, bool value); |
123 | 136 |
124 /** | 137 /** |
125 * Append the given data to the data being collected by this builder. The info
rmation is declared | 138 * 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 | 139 * to potentially contain data that is either user identifiable or contains us
er intellectual |
127 * property (but is not guaranteed to contain either). | 140 * property (but is not guaranteed to contain either). |
| 141 * |
128 * @param name the name used to identify the data | 142 * @param name the name used to identify the data |
129 * @param value the value of the data to be collected | 143 * @param value the value of the data to be collected |
130 * @return this builder | 144 * @return this builder |
131 */ | 145 */ |
132 InstrumentationBuilder data2(String name, int value); | 146 InstrumentationBuilder data2(String name, int value); |
133 | 147 |
134 /** | 148 /** |
135 * Append the given data to the data being collected by this builder. The info
rmation is declared | 149 * Append the given data to the data being collected by this builder. The info
rmation is declared |
136 * to potentially contain data that is either user identifiable or contains us
er intellectual | 150 * to potentially contain data that is either user identifiable or contains us
er intellectual |
137 * property (but is not guaranteed to contain either). | 151 * property (but is not guaranteed to contain either). |
| 152 * |
138 * @param name the name used to identify the data | 153 * @param name the name used to identify the data |
139 * @param value the value of the data to be collected | 154 * @param value the value of the data to be collected |
140 * @return this builder | 155 * @return this builder |
141 */ | 156 */ |
142 InstrumentationBuilder data3(String name, String value); | 157 InstrumentationBuilder data3(String name, String value); |
143 | 158 |
144 /** | 159 /** |
145 * Append the given data to the data being collected by this builder. The info
rmation is declared | 160 * 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 | 161 * to potentially contain data that is either user identifiable or contains us
er intellectual |
147 * property (but is not guaranteed to contain either). | 162 * property (but is not guaranteed to contain either). |
| 163 * |
148 * @param name the name used to identify the data | 164 * @param name the name used to identify the data |
149 * @param value the value of the data to be collected | 165 * @param value the value of the data to be collected |
150 * @return this builder | 166 * @return this builder |
151 */ | 167 */ |
152 InstrumentationBuilder data4(String name, List<String> value); | 168 InstrumentationBuilder data4(String name, List<String> value); |
153 | 169 |
154 /** | 170 /** |
155 * Answer the [InstrumentationLevel] of this `InstrumentationBuilder`. | 171 * Answer the [InstrumentationLevel] of this `InstrumentationBuilder`. |
156 * @return one of [InstrumentationLevel#EVERYTHING], [InstrumentationLevel#MET
RICS],[InstrumentationLevel#OFF] | 172 * |
| 173 * @return one of [InstrumentationLevel#EVERYTHING], [InstrumentationLevel#MET
RICS], |
| 174 * [InstrumentationLevel#OFF] |
157 */ | 175 */ |
158 InstrumentationLevel get instrumentationLevel; | 176 InstrumentationLevel get instrumentationLevel; |
159 | 177 |
160 /** | 178 /** |
161 * Log the data that has been collected. The instrumentation builder should no
t be used after this | 179 * Log the data that has been collected. The instrumentation builder should no
t be used after this |
162 * method is invoked. The behavior of any method defined on this interface tha
t is used after this | 180 * method is invoked. The behavior of any method defined on this interface tha
t is used after this |
163 * method is invoked is undefined. | 181 * method is invoked is undefined. |
164 */ | 182 */ |
165 void log(); | 183 void log(); |
166 | 184 |
167 /** | 185 /** |
168 * Append the given metric to the data being collected by this builder. The in
formation is | 186 * Append the given metric to the data being collected by this builder. The in
formation is |
169 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | 187 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain |
170 * user intellectual property). | 188 * user intellectual property). |
| 189 * |
171 * @param name the name used to identify the data | 190 * @param name the name used to identify the data |
172 * @param value the value of the data to be collected | 191 * @param value the value of the data to be collected |
173 * @return this builder | 192 * @return this builder |
174 */ | 193 */ |
175 InstrumentationBuilder metric(String name, bool value); | 194 InstrumentationBuilder metric(String name, bool value); |
176 | 195 |
177 /** | 196 /** |
178 * Append the given metric to the data being collected by this builder. The in
formation is | 197 * Append the given metric to the data being collected by this builder. The in
formation is |
179 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | 198 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain |
180 * user intellectual property). | 199 * user intellectual property). |
| 200 * |
181 * @param name the name used to identify the data | 201 * @param name the name used to identify the data |
182 * @param value the value of the data to be collected | 202 * @param value the value of the data to be collected |
183 * @return this builder | 203 * @return this builder |
184 */ | 204 */ |
185 InstrumentationBuilder metric2(String name, int value); | 205 InstrumentationBuilder metric2(String name, int value); |
186 | 206 |
187 /** | 207 /** |
188 * Append the given metric to the data being collected by this builder. The in
formation is | 208 * Append the given metric to the data being collected by this builder. The in
formation is |
189 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | 209 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain |
190 * user intellectual property). | 210 * user intellectual property). |
| 211 * |
191 * @param name the name used to identify the data | 212 * @param name the name used to identify the data |
192 * @param value the value of the data to be collected | 213 * @param value the value of the data to be collected |
193 * @return this builder | 214 * @return this builder |
194 */ | 215 */ |
195 InstrumentationBuilder metric3(String name, String value); | 216 InstrumentationBuilder metric3(String name, String value); |
196 | 217 |
197 /** | 218 /** |
198 * Append the given metric to the data being collected by this builder. The in
formation is | 219 * Append the given metric to the data being collected by this builder. The in
formation is |
199 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | 220 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain |
200 * user intellectual property). | 221 * user intellectual property). |
| 222 * |
201 * @param name the name used to identify the data | 223 * @param name the name used to identify the data |
202 * @param value the value of the data to be collected | 224 * @param value the value of the data to be collected |
203 * @return this builder | 225 * @return this builder |
204 */ | 226 */ |
205 InstrumentationBuilder metric4(String name, List<String> value); | 227 InstrumentationBuilder metric4(String name, List<String> value); |
206 | 228 |
207 /** | 229 /** |
208 * Append the given exception to the information being collected by this build
er. The exception's | 230 * Append the given exception to the information being collected by this build
er. The exception's |
209 * class name is captured using [metric]. Other aspects of the exception | 231 * class name is captured using [metric]. Other aspects of the exception |
210 * may contain either user identifiable or contains user intellectual property
(but is not | 232 * may contain either user identifiable or contains user intellectual property
(but is not |
211 * guaranteed to contain either) and thus are captured using the various data
methods such as[data]. | 233 * guaranteed to contain either) and thus are captured using the various data
methods such as |
| 234 * [data]. |
| 235 * |
212 * @param exception the exception (may be `null`) | 236 * @param exception the exception (may be `null`) |
213 */ | 237 */ |
214 InstrumentationBuilder record(Exception exception); | 238 InstrumentationBuilder record(Exception exception); |
215 } | 239 } |
216 /** | 240 /** |
217 * The instrumentation recording level representing (1) recording [EVERYTHING] r
ecording of | 241 * The instrumentation recording level representing (1) recording [EVERYTHING] r
ecording of |
218 * all instrumentation data, (2) recording only [METRICS] information, or (3) re
cording | 242 * all instrumentation data, (2) recording only [METRICS] information, or (3) re
cording |
219 * turned [OFF] in which case nothing is recorded. | 243 * turned [OFF] in which case nothing is recorded. |
| 244 * |
220 * @coverage dart.engine.utilities | 245 * @coverage dart.engine.utilities |
221 */ | 246 */ |
222 class InstrumentationLevel implements Comparable<InstrumentationLevel> { | 247 class InstrumentationLevel implements Comparable<InstrumentationLevel> { |
223 | 248 |
224 /** | 249 /** Recording all instrumented information */ |
225 * Recording all instrumented information | |
226 */ | |
227 static final InstrumentationLevel EVERYTHING = new InstrumentationLevel('EVERY
THING', 0); | 250 static final InstrumentationLevel EVERYTHING = new InstrumentationLevel('EVERY
THING', 0); |
228 | 251 |
229 /** | 252 /** Recording only metrics */ |
230 * Recording only metrics | |
231 */ | |
232 static final InstrumentationLevel METRICS = new InstrumentationLevel('METRICS'
, 1); | 253 static final InstrumentationLevel METRICS = new InstrumentationLevel('METRICS'
, 1); |
233 | 254 |
234 /** | 255 /** Nothing recorded */ |
235 * Nothing recorded | |
236 */ | |
237 static final InstrumentationLevel OFF = new InstrumentationLevel('OFF', 2); | 256 static final InstrumentationLevel OFF = new InstrumentationLevel('OFF', 2); |
238 static final List<InstrumentationLevel> values = [EVERYTHING, METRICS, OFF]; | 257 static final List<InstrumentationLevel> values = [EVERYTHING, METRICS, OFF]; |
239 | 258 |
240 /// The name of this enum constant, as declared in the enum declaration. | 259 /// The name of this enum constant, as declared in the enum declaration. |
241 final String name; | 260 final String name; |
242 | 261 |
243 /// The position in the enum declaration. | 262 /// The position in the enum declaration. |
244 final int ordinal; | 263 final int ordinal; |
245 static InstrumentationLevel fromString(String str) { | 264 static InstrumentationLevel fromString(String str) { |
246 if (str == "EVERYTHING") { | 265 if (str == "EVERYTHING") { |
(...skipping 11 matching lines...) Expand all Loading... |
258 } | 277 } |
259 int compareTo(InstrumentationLevel other) => ordinal - other.ordinal; | 278 int compareTo(InstrumentationLevel other) => ordinal - other.ordinal; |
260 int get hashCode => ordinal; | 279 int get hashCode => ordinal; |
261 String toString() => name; | 280 String toString() => name; |
262 } | 281 } |
263 /** | 282 /** |
264 * The interface `InstrumentationLogger` defines the behavior of objects that ar
e used to log | 283 * The interface `InstrumentationLogger` defines the behavior of objects that ar
e used to log |
265 * instrumentation data. | 284 * instrumentation data. |
266 * | 285 * |
267 * For an example of using objects that implement this interface, see [Instrumen
tation]. | 286 * For an example of using objects that implement this interface, see [Instrumen
tation]. |
| 287 * |
268 * @coverage dart.engine.utilities | 288 * @coverage dart.engine.utilities |
269 */ | 289 */ |
270 abstract class InstrumentationLogger { | 290 abstract class InstrumentationLogger { |
271 | 291 |
272 /** | 292 /** |
273 * Create a builder that can collect the data associated with an operation ide
ntified by the given | 293 * Create a builder that can collect the data associated with an operation ide
ntified by the given |
274 * name. | 294 * name. |
| 295 * |
275 * @param name the name used to uniquely identify the operation | 296 * @param name the name used to uniquely identify the operation |
276 * @return the builder that was created | 297 * @return the builder that was created |
277 */ | 298 */ |
278 InstrumentationBuilder createBuilder(String name); | 299 InstrumentationBuilder createBuilder(String name); |
279 } | 300 } |
OLD | NEW |