| OLD | NEW |
| (Empty) |
| 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. | |
| 3 | |
| 4 library engine.instrumentation; | |
| 5 | |
| 6 import 'java_core.dart'; | |
| 7 | |
| 8 /** | |
| 9 * The class {@code Instrumentation} implements support for logging instrumentat
ion information. | |
| 10 * <p> | |
| 11 * Instrumentation information consists of information about specific operations
. Those operations | |
| 12 * can range from user-facing operations, such as saving the changes to a file,
to internal | |
| 13 * operations, such as tokenizing source code. The information to be logged is g
athered by{@link InstrumentationBuilder instrumentation builder}, created by one
of the static methods on | |
| 14 * this class such as {@link #builder(Class)} or {@link #builder(String)}. | |
| 15 * <p> | |
| 16 * Note, however, that until an instrumentation logger is installed using the me
thod{@link #setLogger(InstrumentationLogger)}, all instrumentation data will be
lost. | |
| 17 * <p> | |
| 18 * <b>Example</b> | |
| 19 * <p> | |
| 20 * To collect metrics about how long it took to save a file, you would write som
ething like the | |
| 21 * following: | |
| 22 * <pre> | |
| 23 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas
s()); | |
| 24 * // save the file | |
| 25 * instrumentation.metric("chars", fileLength).log(); | |
| 26 * </pre> | |
| 27 * The {@code Instrumentation.builder} method creates a new {@link Instrumentati
onBuilderinstrumentation builder} and records the time at which it was created.
The{@link InstrumentationBuilder#metric(String,long)} appends the information sp
ecified by the | |
| 28 * arguments and records the time at which the method is called so that the time
to complete the | |
| 29 * save operation can be calculated. The {@code log} method tells the builder th
at all of the data | |
| 30 * has been collected and that the resulting information should be logged. | |
| 31 * @coverage dart.engine.utilities | |
| 32 */ | |
| 33 class Instrumentation { | |
| 34 /** | |
| 35 * A builder that will silently ignore all data and logging requests. | |
| 36 */ | |
| 37 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new Instrumentat
ionBuilder_8(); | |
| 38 /** | |
| 39 * An instrumentation logger that can be used when no other instrumentation lo
gger has been | |
| 40 * configured. This logger will silently ignore all data and logging requests. | |
| 41 */ | |
| 42 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_9(); | |
| 43 /** | |
| 44 * The current instrumentation logger. | |
| 45 */ | |
| 46 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER; | |
| 47 /** | |
| 48 * Create a builder that can collect the data associated with an operation. | |
| 49 * @param clazz the class performing the operation (not {@code null}) | |
| 50 * @return the builder that was created (not {@code null}) | |
| 51 */ | |
| 52 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui
lder(clazz.toString()); | |
| 53 /** | |
| 54 * Create a builder that can collect the data associated with an operation. | |
| 55 * @param name the name used to uniquely identify the operation (not {@code nu
ll}) | |
| 56 * @return the builder that was created (not {@code null}) | |
| 57 */ | |
| 58 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB
uilder(name); | |
| 59 /** | |
| 60 * Return a builder that will silently ignore all data and logging requests. | |
| 61 * @return the builder (not {@code null}) | |
| 62 */ | |
| 63 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER
; | |
| 64 /** | |
| 65 * Set the logger that should receive instrumentation information to the given
logger. | |
| 66 * @param logger the logger that should receive instrumentation information | |
| 67 */ | |
| 68 static void set logger(InstrumentationLogger logger3) { | |
| 69 _CURRENT_LOGGER = logger3 == null ? _NULL_LOGGER : logger3; | |
| 70 } | |
| 71 /** | |
| 72 * Prevent the creation of instances of this class | |
| 73 */ | |
| 74 Instrumentation() { | |
| 75 } | |
| 76 } | |
| 77 class InstrumentationBuilder_8 implements InstrumentationBuilder { | |
| 78 InstrumentationBuilder data(String name, int value) => this; | |
| 79 InstrumentationBuilder data2(String name, String value) => this; | |
| 80 InstrumentationBuilder data3(String name, List<String> value) => this; | |
| 81 InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF; | |
| 82 void log() { | |
| 83 } | |
| 84 InstrumentationBuilder metric(String name, int value) => this; | |
| 85 InstrumentationBuilder metric2(String name, String value) => this; | |
| 86 InstrumentationBuilder metric3(String name, List<String> value) => this; | |
| 87 } | |
| 88 class InstrumentationLogger_9 implements InstrumentationLogger { | |
| 89 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS
TRUMENTATION_BUILDER; | |
| 90 } | |
| 91 /** | |
| 92 * The interface {@code InstrumentationBuilder} defines the behavior of objects
used to collect data | |
| 93 * about an operation that has occurred and record that data through an instrume
ntation logger. | |
| 94 * <p> | |
| 95 * For an example of using objects that implement this interface, see {@link Ins
trumentation}. | |
| 96 * @coverage dart.engine.utilities | |
| 97 */ | |
| 98 abstract class InstrumentationBuilder { | |
| 99 /** | |
| 100 * Append the given data to the data being collected by this builder. The info
rmation is declared | |
| 101 * to potentially contain data that is either user identifiable or contains us
er intellectual | |
| 102 * property (but is not guaranteed to contain either). | |
| 103 * @param name the name used to identify the data | |
| 104 * @param value the value of the data to be collected | |
| 105 * @return this builder | |
| 106 */ | |
| 107 InstrumentationBuilder data(String name, int value); | |
| 108 /** | |
| 109 * Append the given data to the data being collected by this builder. The info
rmation is declared | |
| 110 * to potentially contain data that is either user identifiable or contains us
er intellectual | |
| 111 * property (but is not guaranteed to contain either). | |
| 112 * @param name the name used to identify the data | |
| 113 * @param value the value of the data to be collected | |
| 114 * @return this builder | |
| 115 */ | |
| 116 InstrumentationBuilder data2(String name, String value); | |
| 117 /** | |
| 118 * Append the given data to the data being collected by this builder. The info
rmation is declared | |
| 119 * to potentially contain data that is either user identifiable or contains us
er intellectual | |
| 120 * property (but is not guaranteed to contain either). | |
| 121 * @param name the name used to identify the data | |
| 122 * @param value the value of the data to be collected | |
| 123 * @return this builder | |
| 124 */ | |
| 125 InstrumentationBuilder data3(String name, List<String> value); | |
| 126 /** | |
| 127 * Answer the {@link InstrumentationLevel} of this {@code InstrumentationBuild
er}. | |
| 128 * @return one of {@link InstrumentationLevel#EVERYTHING}, {@link Instrumentat
ionLevel#METRICS},{@link InstrumentationLevel#OFF} | |
| 129 */ | |
| 130 InstrumentationLevel get instrumentationLevel; | |
| 131 /** | |
| 132 * Log the data that has been collected. The instrumentation builder should no
t be used after this | |
| 133 * method is invoked. The behavior of any method defined on this interface tha
t is used after this | |
| 134 * method is invoked is undefined. | |
| 135 */ | |
| 136 void log(); | |
| 137 /** | |
| 138 * Append the given metric to the data being collected by this builder. The in
formation is | |
| 139 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | |
| 140 * user intellectual property). | |
| 141 * @param name the name used to identify the data | |
| 142 * @param value the value of the data to be collected | |
| 143 * @return this builder | |
| 144 */ | |
| 145 InstrumentationBuilder metric(String name, int value); | |
| 146 /** | |
| 147 * Append the given metric to the data being collected by this builder. The in
formation is | |
| 148 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | |
| 149 * user intellectual property). | |
| 150 * @param name the name used to identify the data | |
| 151 * @param value the value of the data to be collected | |
| 152 * @return this builder | |
| 153 */ | |
| 154 InstrumentationBuilder metric2(String name, String value); | |
| 155 /** | |
| 156 * Append the given metric to the data being collected by this builder. The in
formation is | |
| 157 * declared to contain only metrics data (data that is not user identifiable a
nd does not contain | |
| 158 * user intellectual property). | |
| 159 * @param name the name used to identify the data | |
| 160 * @param value the value of the data to be collected | |
| 161 * @return this builder | |
| 162 */ | |
| 163 InstrumentationBuilder metric3(String name, List<String> value); | |
| 164 } | |
| 165 /** | |
| 166 * The instrumentation recording level representing (1) recording {@link #EVERYT
HING} recording of | |
| 167 * all instrumentation data, (2) recording only {@link #METRICS} information, or
(3) recording | |
| 168 * turned {@link #OFF} in which case nothing is recorded. | |
| 169 * @coverage dart.engine.utilities | |
| 170 */ | |
| 171 class InstrumentationLevel { | |
| 172 /** | |
| 173 * Recording all instrumented information | |
| 174 */ | |
| 175 static final InstrumentationLevel EVERYTHING = new InstrumentationLevel('EVERY
THING', 0); | |
| 176 /** | |
| 177 * Recording only metrics | |
| 178 */ | |
| 179 static final InstrumentationLevel METRICS = new InstrumentationLevel('METRICS'
, 1); | |
| 180 /** | |
| 181 * Nothing recorded | |
| 182 */ | |
| 183 static final InstrumentationLevel OFF = new InstrumentationLevel('OFF', 2); | |
| 184 static final List<InstrumentationLevel> values = [EVERYTHING, METRICS, OFF]; | |
| 185 final String __name; | |
| 186 final int __ordinal; | |
| 187 int get ordinal => __ordinal; | |
| 188 InstrumentationLevel(this.__name, this.__ordinal) { | |
| 189 } | |
| 190 String toString() => __name; | |
| 191 } | |
| 192 /** | |
| 193 * The interface {@code InstrumentationLogger} defines the behavior of objects t
hat are used to log | |
| 194 * instrumentation data. | |
| 195 * <p> | |
| 196 * For an example of using objects that implement this interface, see {@link Ins
trumentation}. | |
| 197 * @coverage dart.engine.utilities | |
| 198 */ | |
| 199 abstract class InstrumentationLogger { | |
| 200 /** | |
| 201 * Create a builder that can collect the data associated with an operation ide
ntified by the given | |
| 202 * name. | |
| 203 * @param name the name used to uniquely identify the operation | |
| 204 * @return the builder that was created | |
| 205 */ | |
| 206 InstrumentationBuilder createBuilder(String name); | |
| 207 } | |
| OLD | NEW |