| Index: pkg/analyzer-experimental/lib/src/generated/instrumentation.dart
|
| diff --git a/pkg/analyzer-experimental/lib/src/generated/instrumentation.dart b/pkg/analyzer-experimental/lib/src/generated/instrumentation.dart
|
| index fbf9994cd4a7db4052324ae456bc05aa0137176e..7963b27d8039ec004508e21d6d1ad8973bc89156 100644
|
| --- a/pkg/analyzer-experimental/lib/src/generated/instrumentation.dart
|
| +++ b/pkg/analyzer-experimental/lib/src/generated/instrumentation.dart
|
| @@ -6,92 +6,12 @@ library engine.instrumentation;
|
| import 'java_core.dart';
|
|
|
| /**
|
| - * The interface {@code OperationBuilder} defines the behavior of objects used to collect data about
|
| - * an operation that has occurred and record that data through an instrumentation logger.
|
| - * <p>
|
| - * For an example of using objects that implement this interface, see {@link Instrumentation}.
|
| - */
|
| -abstract class OperationBuilder {
|
| - /**
|
| - * Log the data that has been collected. The operation builder should not be used after this
|
| - * method is invoked. The behavior of any method defined on this interface that is used after this
|
| - * method is invoked is undefined.
|
| - */
|
| - void log();
|
| - /**
|
| - * Lazily compute and append the given data to the data being collected by this builder.
|
| - * @param name the name used to identify the data
|
| - * @param a function that will be executed in the background to return the value of the data to be
|
| - * collected
|
| - * @return this builder
|
| - */
|
| - OperationBuilder with2(String name, AsyncValue valueGenerator);
|
| - /**
|
| - * Append the given data to the data being collected by this builder.
|
| - * @param name the name used to identify the data
|
| - * @param value the value of the data to be collected
|
| - * @return this builder
|
| - */
|
| - OperationBuilder with3(String name, int value);
|
| - /**
|
| - * Append the given data to the data being collected by this builder.
|
| - * @param name the name used to identify the data
|
| - * @param value the value of the data to be collected
|
| - * @return this builder
|
| - */
|
| - OperationBuilder with4(String name, String value);
|
| - /**
|
| - * Append the given data to the data being collected by this builder.
|
| - * @param name the name used to identify the data
|
| - * @param value the value of the data to be collected
|
| - * @return this builder
|
| - */
|
| - OperationBuilder with5(String name, List<String> value);
|
| -}
|
| -/**
|
| - * The interface {@code InstrumentationLogger} defines the behavior of objects that are used to log
|
| - * instrumentation data.
|
| - * <p>
|
| - * For an example of using objects that implement this interface, see {@link Instrumentation}.
|
| - */
|
| -abstract class InstrumentationLogger {
|
| - /**
|
| - * Create an operation builder that can collect the data associated with an operation. The
|
| - * operation is identified by the given name, is declared to contain only metrics data (data that
|
| - * is not user identifiable and does not contain user intellectual property), and took the given
|
| - * amount of time to complete.
|
| - * @param name the name used to uniquely identify the operation
|
| - * @param time the number of milliseconds required to perform the operation, or {@code -1} if the
|
| - * time is not available or not applicable to this kind of operation
|
| - * @return the operation builder that was created
|
| - */
|
| - OperationBuilder createMetric(String name, int time);
|
| - /**
|
| - * Create an operation builder that can collect the data associated with an operation. The
|
| - * operation is identified by the given name, is declared to potentially contain data that is
|
| - * either user identifiable or contains user intellectual property (but is not guaranteed to
|
| - * contain either), and took the given amount of time to complete.
|
| - * @param name the name used to uniquely identify the operation
|
| - * @param time the number of milliseconds required to perform the operation, or {@code -1} if the
|
| - * time is not available or not applicable to this kind of operation
|
| - * @return the operation builder that was created
|
| - */
|
| - OperationBuilder createOperation(String name, int time);
|
| -}
|
| -abstract class AsyncValue {
|
| - /**
|
| - * Returns a String to be logged This would typically be used with an anonymous implementation
|
| - * closing over some variables with an expensive operation to be performed in the background
|
| - * @return The data to be logged
|
| - */
|
| - String compute();
|
| -}
|
| -/**
|
| * The class {@code Instrumentation} implements support for logging instrumentation information.
|
| * <p>
|
| * Instrumentation information consists of information about specific operations. Those operations
|
| * can range from user-facing operations, such as saving the changes to a file, to internal
|
| - * operations, such as tokenizing source code. The information to be logged is gathered by an{@link OperationBuilder operation builder}, created by one of the static methods on this class.
|
| + * operations, such as tokenizing source code. The information to be logged is gathered by{@link InstrumentationBuilder instrumentation builder}, created by one of the static methods on
|
| + * this class such as {@link #builder(Class)} or {@link #builder(String)}.
|
| * <p>
|
| * Note, however, that until an instrumentation logger is installed using the method{@link #setLogger(InstrumentationLogger)}, all instrumentation data will be lost.
|
| * <p>
|
| @@ -100,64 +20,46 @@ abstract class AsyncValue {
|
| * To collect metrics about how long it took to save a file, you would write something like the
|
| * following:
|
| * <pre>
|
| - * long startTime = System.currentTimeMillis();
|
| + * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClass());
|
| * // save the file
|
| - * long endTime = System.currentTimeMillis();
|
| - * metric("Save", endTime - startTime).with("chars", fileLength).log();
|
| + * instrumentation.metric("chars", fileLength).log();
|
| * </pre>
|
| - * The {@code metric} method creates an operation builder for an operation named {@code "Save"} that
|
| - * took {@code endTime - startTime} milliseconds to run. The {@code with} method attaches additional
|
| - * data to the operation; in this case recording that the file was {@code fileLength} characters
|
| - * long. The {@code log} method tells the builder that all of the data has been collected and that
|
| - * the resulting information should be logged.
|
| + * The {@code Instrumentation.builder} method creates a new {@link InstrumentationBuilderinstrumentation builder} and records the time at which it was created. The{@link InstrumentationBuilder#metric(String,long)} appends the information specified by the
|
| + * arguments and records the time at which the method is called so that the time to complete the
|
| + * save operation can be calculated. The {@code log} method tells the builder that all of the data
|
| + * has been collected and that the resulting information should be logged.
|
| */
|
| class Instrumentation {
|
| /**
|
| + * A builder that will silently ignore all data and logging requests.
|
| + */
|
| + static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new InstrumentationBuilder_7();
|
| + /**
|
| * An instrumentation logger that can be used when no other instrumentation logger has been
|
| * configured. This logger will silently ignore all data and logging requests.
|
| */
|
| - static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_5();
|
| + static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_8();
|
| /**
|
| * The current instrumentation logger.
|
| */
|
| static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER;
|
| /**
|
| - * Create an operation builder that can collect the data associated with an operation. The
|
| - * operation is identified by the given name and is declared to contain only metrics data (data
|
| - * that is not user identifiable and does not contain user intellectual property).
|
| - * @param name the name used to uniquely identify the operation
|
| - * @return the operation builder that was created
|
| - */
|
| - static OperationBuilder metric(String name) => _CURRENT_LOGGER.createMetric(name, -1);
|
| - /**
|
| - * Create an operation builder that can collect the data associated with an operation. The
|
| - * operation is identified by the given name, is declared to contain only metrics data (data that
|
| - * is not user identifiable and does not contain user intellectual property), and took the given
|
| - * amount of time to complete.
|
| - * @param name the name used to uniquely identify the operation
|
| - * @param time the number of milliseconds required to perform the operation
|
| - * @return the operation builder that was created
|
| + * Create a builder that can collect the data associated with an operation.
|
| + * @param clazz the class performing the operation (not {@code null})
|
| + * @return the builder that was created (not {@code null})
|
| */
|
| - static OperationBuilder metric2(String name, int time) => _CURRENT_LOGGER.createMetric(name, time);
|
| + static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBuilder(clazz.toString());
|
| /**
|
| - * Create an operation builder that can collect the data associated with an operation. The
|
| - * operation is identified by the given name and is declared to potentially contain data that is
|
| - * either user identifiable or contains user intellectual property (but is not guaranteed to
|
| - * contain either).
|
| - * @param name the name used to uniquely identify the operation
|
| - * @return the operation builder that was created
|
| + * Create a builder that can collect the data associated with an operation.
|
| + * @param name the name used to uniquely identify the operation (not {@code null})
|
| + * @return the builder that was created (not {@code null})
|
| */
|
| - static OperationBuilder operation(String name) => _CURRENT_LOGGER.createOperation(name, -1);
|
| + static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createBuilder(name);
|
| /**
|
| - * Create an operation builder that can collect the data associated with an operation. The
|
| - * operation is identified by the given name, is declared to potentially contain data that is
|
| - * either user identifiable or contains user intellectual property (but is not guaranteed to
|
| - * contain either), and took the given amount of time to complete.
|
| - * @param name the name used to uniquely identify the operation
|
| - * @param time the number of milliseconds required to perform the operation
|
| - * @return the operation builder that was created
|
| + * Return a builder that will silently ignore all data and logging requests.
|
| + * @return the builder (not {@code null})
|
| */
|
| - static OperationBuilder operation2(String name, int time) => _CURRENT_LOGGER.createOperation(name, time);
|
| + static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER;
|
| /**
|
| * Set the logger that should receive instrumentation information to the given logger.
|
| * @param logger the logger that should receive instrumentation information
|
| @@ -171,19 +73,130 @@ class Instrumentation {
|
| Instrumentation() {
|
| }
|
| }
|
| -class InstrumentationLogger_5 implements InstrumentationLogger {
|
| +class InstrumentationBuilder_7 implements InstrumentationBuilder {
|
| + InstrumentationBuilder data(String name, int value) => this;
|
| + InstrumentationBuilder data2(String name, String value) => this;
|
| + InstrumentationBuilder data3(String name, List<String> value) => this;
|
| + InstrumentationLevel get instrumentationLevel => InstrumentationLevel.OFF;
|
| + void log() {
|
| + }
|
| + InstrumentationBuilder metric(String name, int value) => this;
|
| + InstrumentationBuilder metric2(String name, String value) => this;
|
| + InstrumentationBuilder metric3(String name, List<String> value) => this;
|
| +}
|
| +class InstrumentationLogger_8 implements InstrumentationLogger {
|
| + InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INSTRUMENTATION_BUILDER;
|
| +}
|
| +/**
|
| + * The interface {@code InstrumentationBuilder} defines the behavior of objects used to collect data
|
| + * about an operation that has occurred and record that data through an instrumentation logger.
|
| + * <p>
|
| + * For an example of using objects that implement this interface, see {@link Instrumentation}.
|
| + */
|
| +abstract class InstrumentationBuilder {
|
| + /**
|
| + * Append the given data to the data being collected by this builder. The information is declared
|
| + * to potentially contain data that is either user identifiable or contains user intellectual
|
| + * property (but is not guaranteed to contain either).
|
| + * @param name the name used to identify the data
|
| + * @param value the value of the data to be collected
|
| + * @return this builder
|
| + */
|
| + InstrumentationBuilder data(String name, int value);
|
| + /**
|
| + * Append the given data to the data being collected by this builder. The information is declared
|
| + * to potentially contain data that is either user identifiable or contains user intellectual
|
| + * property (but is not guaranteed to contain either).
|
| + * @param name the name used to identify the data
|
| + * @param value the value of the data to be collected
|
| + * @return this builder
|
| + */
|
| + InstrumentationBuilder data2(String name, String value);
|
| + /**
|
| + * Append the given data to the data being collected by this builder. The information is declared
|
| + * to potentially contain data that is either user identifiable or contains user intellectual
|
| + * property (but is not guaranteed to contain either).
|
| + * @param name the name used to identify the data
|
| + * @param value the value of the data to be collected
|
| + * @return this builder
|
| + */
|
| + InstrumentationBuilder data3(String name, List<String> value);
|
| + /**
|
| + * Answer the {@link InstrumentationLevel} of this {@code InstrumentationBuilder}.
|
| + * @return one of {@link InstrumentationLevel#EVERYTHING}, {@link InstrumentationLevel#METRICS},{@link InstrumentationLevel#OFF}
|
| + */
|
| + InstrumentationLevel get instrumentationLevel;
|
| + /**
|
| + * Log the data that has been collected. The instrumentation builder should not be used after this
|
| + * method is invoked. The behavior of any method defined on this interface that is used after this
|
| + * method is invoked is undefined.
|
| + */
|
| + void log();
|
| + /**
|
| + * Append the given metric to the data being collected by this builder. The information is
|
| + * declared to contain only metrics data (data that is not user identifiable and does not contain
|
| + * user intellectual property).
|
| + * @param name the name used to identify the data
|
| + * @param value the value of the data to be collected
|
| + * @return this builder
|
| + */
|
| + InstrumentationBuilder metric(String name, int value);
|
| /**
|
| - * An operation builder that will silently ignore all data and logging requests.
|
| + * Append the given metric to the data being collected by this builder. The information is
|
| + * declared to contain only metrics data (data that is not user identifiable and does not contain
|
| + * user intellectual property).
|
| + * @param name the name used to identify the data
|
| + * @param value the value of the data to be collected
|
| + * @return this builder
|
| */
|
| - OperationBuilder _NULL_BUILDER = new OperationBuilder_6();
|
| - OperationBuilder createMetric(String name, int time) => _NULL_BUILDER;
|
| - OperationBuilder createOperation(String name, int time) => _NULL_BUILDER;
|
| + InstrumentationBuilder metric2(String name, String value);
|
| + /**
|
| + * Append the given metric to the data being collected by this builder. The information is
|
| + * declared to contain only metrics data (data that is not user identifiable and does not contain
|
| + * user intellectual property).
|
| + * @param name the name used to identify the data
|
| + * @param value the value of the data to be collected
|
| + * @return this builder
|
| + */
|
| + InstrumentationBuilder metric3(String name, List<String> value);
|
| }
|
| -class OperationBuilder_6 implements OperationBuilder {
|
| - void log() {
|
| +/**
|
| + * The instrumentation recording level representing (1) recording {@link #EVERYTHING} recording of
|
| + * all instrumentation data, (2) recording only {@link #METRICS} information, or (3) recording
|
| + * turned {@link #OFF} in which case nothing is recorded.
|
| + */
|
| +class InstrumentationLevel {
|
| + /**
|
| + * Recording all instrumented information
|
| + */
|
| + static final InstrumentationLevel EVERYTHING = new InstrumentationLevel('EVERYTHING', 0);
|
| + /**
|
| + * Recording only metrics
|
| + */
|
| + static final InstrumentationLevel METRICS = new InstrumentationLevel('METRICS', 1);
|
| + /**
|
| + * Nothing recorded
|
| + */
|
| + static final InstrumentationLevel OFF = new InstrumentationLevel('OFF', 2);
|
| + static final List<InstrumentationLevel> values = [EVERYTHING, METRICS, OFF];
|
| + final String __name;
|
| + final int __ordinal;
|
| + InstrumentationLevel(this.__name, this.__ordinal) {
|
| }
|
| - OperationBuilder with2(String name, AsyncValue valueGenerator) => this;
|
| - OperationBuilder with3(String name, int value) => this;
|
| - OperationBuilder with4(String name, String value) => this;
|
| - OperationBuilder with5(String name, List<String> value) => this;
|
| + String toString() => __name;
|
| +}
|
| +/**
|
| + * The interface {@code InstrumentationLogger} defines the behavior of objects that are used to log
|
| + * instrumentation data.
|
| + * <p>
|
| + * For an example of using objects that implement this interface, see {@link Instrumentation}.
|
| + */
|
| +abstract class InstrumentationLogger {
|
| + /**
|
| + * Create a builder that can collect the data associated with an operation identified by the given
|
| + * name.
|
| + * @param name the name used to uniquely identify the operation
|
| + * @return the builder that was created
|
| + */
|
| + InstrumentationBuilder createBuilder(String name);
|
| }
|
|
|