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

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

Issue 12502002: Update analyzer-experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months 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
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 3
4 library engine.instrumentation; 4 library engine.instrumentation;
5 5
6 import 'java_core.dart'; 6 import 'java_core.dart';
7 7
8 /** 8 /**
9 * The interface {@code OperationBuilder} defines the behavior of objects used t o collect data about
10 * an operation that has occurred and record that data through an instrumentatio n logger.
11 * <p>
12 * For an example of using objects that implement this interface, see {@link Ins trumentation}.
13 */
14 abstract class OperationBuilder {
15 /**
16 * Log the data that has been collected. The operation builder should not be u sed after this
17 * method is invoked. The behavior of any method defined on this interface tha t is used after this
18 * method is invoked is undefined.
19 */
20 void log();
21 /**
22 * Lazily compute and append the given data to the data being collected by thi s builder.
23 * @param name the name used to identify the data
24 * @param a function that will be executed in the background to return the val ue of the data to be
25 * collected
26 * @return this builder
27 */
28 OperationBuilder with2(String name, AsyncValue valueGenerator);
29 /**
30 * Append the given data to the data being collected by this builder.
31 * @param name the name used to identify the data
32 * @param value the value of the data to be collected
33 * @return this builder
34 */
35 OperationBuilder with3(String name, int value);
36 /**
37 * Append the given data to the data being collected by this builder.
38 * @param name the name used to identify the data
39 * @param value the value of the data to be collected
40 * @return this builder
41 */
42 OperationBuilder with4(String name, String value);
43 /**
44 * Append the given data to the data being collected by this builder.
45 * @param name the name used to identify the data
46 * @param value the value of the data to be collected
47 * @return this builder
48 */
49 OperationBuilder with5(String name, List<String> value);
50 }
51 /**
52 * The interface {@code InstrumentationLogger} defines the behavior of objects t hat are used to log
53 * instrumentation data.
54 * <p>
55 * For an example of using objects that implement this interface, see {@link Ins trumentation}.
56 */
57 abstract class InstrumentationLogger {
58 /**
59 * Create an operation builder that can collect the data associated with an op eration. The
60 * operation is identified by the given name, is declared to contain only metr ics data (data that
61 * is not user identifiable and does not contain user intellectual property), and took the given
62 * amount of time to complete.
63 * @param name the name used to uniquely identify the operation
64 * @param time the number of milliseconds required to perform the operation, o r {@code -1} if the
65 * time is not available or not applicable to this kind of operation
66 * @return the operation builder that was created
67 */
68 OperationBuilder createMetric(String name, int time);
69 /**
70 * Create an operation builder that can collect the data associated with an op eration. The
71 * operation is identified by the given name, is declared to potentially conta in data that is
72 * either user identifiable or contains user intellectual property (but is not guaranteed to
73 * contain either), and took the given amount of time to complete.
74 * @param name the name used to uniquely identify the operation
75 * @param time the number of milliseconds required to perform the operation, o r {@code -1} if the
76 * time is not available or not applicable to this kind of operation
77 * @return the operation builder that was created
78 */
79 OperationBuilder createOperation(String name, int time);
80 }
81 abstract class AsyncValue {
82 /**
83 * Returns a String to be logged This would typically be used with an anonymou s implementation
84 * closing over some variables with an expensive operation to be performed in the background
85 * @return The data to be logged
86 */
87 String compute();
88 }
89 /**
90 * The class {@code Instrumentation} implements support for logging instrumentat ion information. 9 * The class {@code Instrumentation} implements support for logging instrumentat ion information.
91 * <p> 10 * <p>
92 * Instrumentation information consists of information about specific operations . Those operations 11 * Instrumentation information consists of information about specific operations . Those operations
93 * can range from user-facing operations, such as saving the changes to a file, to internal 12 * can range from user-facing operations, such as saving the changes to a file, to internal
94 * operations, such as tokenizing source code. The information to be logged is g athered by an{@link OperationBuilder operation builder}, created by one of the s tatic methods on this class. 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)}.
95 * <p> 15 * <p>
96 * Note, however, that until an instrumentation logger is installed using the me thod{@link #setLogger(InstrumentationLogger)}, all instrumentation data will be lost. 16 * Note, however, that until an instrumentation logger is installed using the me thod{@link #setLogger(InstrumentationLogger)}, all instrumentation data will be lost.
97 * <p> 17 * <p>
98 * <b>Example</b> 18 * <b>Example</b>
99 * <p> 19 * <p>
100 * To collect metrics about how long it took to save a file, you would write som ething like the 20 * To collect metrics about how long it took to save a file, you would write som ething like the
101 * following: 21 * following:
102 * <pre> 22 * <pre>
103 * long startTime = System.currentTimeMillis(); 23 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas s());
104 * // save the file 24 * // save the file
105 * long endTime = System.currentTimeMillis(); 25 * instrumentation.metric("chars", fileLength).log();
106 * metric("Save", endTime - startTime).with("chars", fileLength).log();
107 * </pre> 26 * </pre>
108 * The {@code metric} method creates an operation builder for an operation named {@code "Save"} that 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
109 * took {@code endTime - startTime} milliseconds to run. The {@code with} method attaches additional 28 * arguments and records the time at which the method is called so that the time to complete the
110 * data to the operation; in this case recording that the file was {@code fileLe ngth} characters 29 * save operation can be calculated. The {@code log} method tells the builder th at all of the data
111 * long. The {@code log} method tells the builder that all of the data has been collected and that 30 * has been collected and that the resulting information should be logged.
112 * the resulting information should be logged.
113 */ 31 */
114 class Instrumentation { 32 class Instrumentation {
115 /** 33 /**
34 * A builder that will silently ignore all data and logging requests.
35 */
36 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new Instrumentat ionBuilder_7();
37 /**
116 * An instrumentation logger that can be used when no other instrumentation lo gger has been 38 * An instrumentation logger that can be used when no other instrumentation lo gger has been
117 * configured. This logger will silently ignore all data and logging requests. 39 * configured. This logger will silently ignore all data and logging requests.
118 */ 40 */
119 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_5(); 41 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_8();
120 /** 42 /**
121 * The current instrumentation logger. 43 * The current instrumentation logger.
122 */ 44 */
123 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER; 45 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER;
124 /** 46 /**
125 * Create an operation builder that can collect the data associated with an op eration. The 47 * Create a builder that can collect the data associated with an operation.
126 * operation is identified by the given name and is declared to contain only m etrics data (data 48 * @param clazz the class performing the operation (not {@code null})
127 * that is not user identifiable and does not contain user intellectual proper ty). 49 * @return the builder that was created (not {@code null})
128 * @param name the name used to uniquely identify the operation
129 * @return the operation builder that was created
130 */ 50 */
131 static OperationBuilder metric(String name) => _CURRENT_LOGGER.createMetric(na me, -1); 51 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui lder(clazz.toString());
132 /** 52 /**
133 * Create an operation builder that can collect the data associated with an op eration. The 53 * Create a builder that can collect the data associated with an operation.
134 * operation is identified by the given name, is declared to contain only metr ics data (data that 54 * @param name the name used to uniquely identify the operation (not {@code nu ll})
135 * is not user identifiable and does not contain user intellectual property), and took the given 55 * @return the builder that was created (not {@code null})
136 * amount of time to complete.
137 * @param name the name used to uniquely identify the operation
138 * @param time the number of milliseconds required to perform the operation
139 * @return the operation builder that was created
140 */ 56 */
141 static OperationBuilder metric2(String name, int time) => _CURRENT_LOGGER.crea teMetric(name, time); 57 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB uilder(name);
142 /** 58 /**
143 * Create an operation builder that can collect the data associated with an op eration. The 59 * Return a builder that will silently ignore all data and logging requests.
144 * operation is identified by the given name and is declared to potentially co ntain data that is 60 * @return the builder (not {@code null})
145 * either user identifiable or contains user intellectual property (but is not guaranteed to
146 * contain either).
147 * @param name the name used to uniquely identify the operation
148 * @return the operation builder that was created
149 */ 61 */
150 static OperationBuilder operation(String name) => _CURRENT_LOGGER.createOperat ion(name, -1); 62 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER ;
151 /**
152 * Create an operation builder that can collect the data associated with an op eration. The
153 * operation is identified by the given name, is declared to potentially conta in data that is
154 * either user identifiable or contains user intellectual property (but is not guaranteed to
155 * contain either), and took the given amount of time to complete.
156 * @param name the name used to uniquely identify the operation
157 * @param time the number of milliseconds required to perform the operation
158 * @return the operation builder that was created
159 */
160 static OperationBuilder operation2(String name, int time) => _CURRENT_LOGGER.c reateOperation(name, time);
161 /** 63 /**
162 * Set the logger that should receive instrumentation information to the given logger. 64 * Set the logger that should receive instrumentation information to the given logger.
163 * @param logger the logger that should receive instrumentation information 65 * @param logger the logger that should receive instrumentation information
164 */ 66 */
165 static void set logger(InstrumentationLogger logger3) { 67 static void set logger(InstrumentationLogger logger3) {
166 _CURRENT_LOGGER = logger3 == null ? _NULL_LOGGER : logger3; 68 _CURRENT_LOGGER = logger3 == null ? _NULL_LOGGER : logger3;
167 } 69 }
168 /** 70 /**
169 * Prevent the creation of instances of this class 71 * Prevent the creation of instances of this class
170 */ 72 */
171 Instrumentation() { 73 Instrumentation() {
172 } 74 }
173 } 75 }
174 class InstrumentationLogger_5 implements InstrumentationLogger { 76 class InstrumentationBuilder_7 implements InstrumentationBuilder {
175 /** 77 InstrumentationBuilder data(String name, int value) => this;
176 * An operation builder that will silently ignore all data and logging request s. 78 InstrumentationBuilder data2(String name, String value) => this;
177 */ 79 InstrumentationBuilder data3(String name, List<String> value) => this;
178 OperationBuilder _NULL_BUILDER = new OperationBuilder_6(); 80 InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF;
179 OperationBuilder createMetric(String name, int time) => _NULL_BUILDER;
180 OperationBuilder createOperation(String name, int time) => _NULL_BUILDER;
181 }
182 class OperationBuilder_6 implements OperationBuilder {
183 void log() { 81 void log() {
184 } 82 }
185 OperationBuilder with2(String name, AsyncValue valueGenerator) => this; 83 InstrumentationBuilder metric(String name, int value) => this;
186 OperationBuilder with3(String name, int value) => this; 84 InstrumentationBuilder metric2(String name, String value) => this;
187 OperationBuilder with4(String name, String value) => this; 85 InstrumentationBuilder metric3(String name, List<String> value) => this;
188 OperationBuilder with5(String name, List<String> value) => this; 86 }
87 class InstrumentationLogger_8 implements InstrumentationLogger {
88 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS TRUMENTATION_BUILDER;
89 }
90 /**
91 * The interface {@code InstrumentationBuilder} defines the behavior of objects used to collect data
92 * about an operation that has occurred and record that data through an instrume ntation logger.
93 * <p>
94 * For an example of using objects that implement this interface, see {@link Ins trumentation}.
95 */
96 abstract class InstrumentationBuilder {
97 /**
98 * Append the given data to the data being collected by this builder. The info rmation is declared
99 * to potentially contain data that is either user identifiable or contains us er intellectual
100 * property (but is not guaranteed to contain either).
101 * @param name the name used to identify the data
102 * @param value the value of the data to be collected
103 * @return this builder
104 */
105 InstrumentationBuilder data(String name, int value);
106 /**
107 * Append the given data to the data being collected by this builder. The info rmation is declared
108 * to potentially contain data that is either user identifiable or contains us er intellectual
109 * property (but is not guaranteed to contain either).
110 * @param name the name used to identify the data
111 * @param value the value of the data to be collected
112 * @return this builder
113 */
114 InstrumentationBuilder data2(String name, String value);
115 /**
116 * Append the given data to the data being collected by this builder. The info rmation is declared
117 * to potentially contain data that is either user identifiable or contains us er intellectual
118 * property (but is not guaranteed to contain either).
119 * @param name the name used to identify the data
120 * @param value the value of the data to be collected
121 * @return this builder
122 */
123 InstrumentationBuilder data3(String name, List<String> value);
124 /**
125 * Answer the {@link InstrumentationLevel} of this {@code InstrumentationBuild er}.
126 * @return one of {@link InstrumentationLevel#EVERYTHING}, {@link Instrumentat ionLevel#METRICS},{@link InstrumentationLevel#OFF}
127 */
128 InstrumentationLevel get instrumentationLevel;
129 /**
130 * Log the data that has been collected. The instrumentation builder should no t be used after this
131 * method is invoked. The behavior of any method defined on this interface tha t is used after this
132 * method is invoked is undefined.
133 */
134 void log();
135 /**
136 * Append the given metric to the data being collected by this builder. The in formation is
137 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
138 * user intellectual property).
139 * @param name the name used to identify the data
140 * @param value the value of the data to be collected
141 * @return this builder
142 */
143 InstrumentationBuilder metric(String name, int value);
144 /**
145 * Append the given metric to the data being collected by this builder. The in formation is
146 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
147 * user intellectual property).
148 * @param name the name used to identify the data
149 * @param value the value of the data to be collected
150 * @return this builder
151 */
152 InstrumentationBuilder metric2(String name, String value);
153 /**
154 * Append the given metric to the data being collected by this builder. The in formation is
155 * declared to contain only metrics data (data that is not user identifiable a nd does not contain
156 * user intellectual property).
157 * @param name the name used to identify the data
158 * @param value the value of the data to be collected
159 * @return this builder
160 */
161 InstrumentationBuilder metric3(String name, List<String> value);
162 }
163 /**
164 * The instrumentation recording level representing (1) recording {@link #EVERYT HING} recording of
165 * all instrumentation data, (2) recording only {@link #METRICS} information, or (3) recording
166 * turned {@link #OFF} in which case nothing is recorded.
167 */
168 class InstrumentationLevel {
169 /**
170 * Recording all instrumented information
171 */
172 static final InstrumentationLevel EVERYTHING = new InstrumentationLevel('EVERY THING', 0);
173 /**
174 * Recording only metrics
175 */
176 static final InstrumentationLevel METRICS = new InstrumentationLevel('METRICS' , 1);
177 /**
178 * Nothing recorded
179 */
180 static final InstrumentationLevel OFF = new InstrumentationLevel('OFF', 2);
181 static final List<InstrumentationLevel> values = [EVERYTHING, METRICS, OFF];
182 final String __name;
183 final int __ordinal;
184 InstrumentationLevel(this.__name, this.__ordinal) {
185 }
186 String toString() => __name;
187 }
188 /**
189 * The interface {@code InstrumentationLogger} defines the behavior of objects t hat are used to log
190 * instrumentation data.
191 * <p>
192 * For an example of using objects that implement this interface, see {@link Ins trumentation}.
193 */
194 abstract class InstrumentationLogger {
195 /**
196 * Create a builder that can collect the data associated with an operation ide ntified by the given
197 * name.
198 * @param name the name used to uniquely identify the operation
199 * @return the builder that was created
200 */
201 InstrumentationBuilder createBuilder(String name);
189 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698