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

Side by Side Diff: pkg/analysis_server/lib/src/server/driver.dart

Issue 859513002: send priority instrumentation message on startup with version info (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and address comments Created 5 years, 11 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library driver; 5 library driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math';
9 10
10 import 'package:analysis_server/plugin/plugin.dart'; 11 import 'package:analysis_server/plugin/plugin.dart';
11 import 'package:analysis_server/src/analysis_server.dart'; 12 import 'package:analysis_server/src/analysis_server.dart';
13 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/plugin/plugin_impl.dart'; 14 import 'package:analysis_server/src/plugin/plugin_impl.dart';
13 import 'package:analysis_server/src/plugin/server_plugin.dart'; 15 import 'package:analysis_server/src/plugin/server_plugin.dart';
14 import 'package:analysis_server/src/server/http_server.dart'; 16 import 'package:analysis_server/src/server/http_server.dart';
15 import 'package:analysis_server/src/server/stdio_server.dart'; 17 import 'package:analysis_server/src/server/stdio_server.dart';
16 import 'package:analysis_server/src/socket_server.dart'; 18 import 'package:analysis_server/src/socket_server.dart';
17 import 'package:analysis_server/starter.dart'; 19 import 'package:analysis_server/starter.dart';
20 import 'package:analyzer/file_system/physical_file_system.dart';
18 import 'package:analyzer/instrumentation/instrumentation.dart'; 21 import 'package:analyzer/instrumentation/instrumentation.dart';
19 import 'package:analyzer/src/generated/engine.dart'; 22 import 'package:analyzer/src/generated/engine.dart';
20 import 'package:analyzer/src/generated/incremental_logger.dart'; 23 import 'package:analyzer/src/generated/incremental_logger.dart';
21 import 'package:analyzer/src/generated/java_io.dart'; 24 import 'package:analyzer/src/generated/java_io.dart';
22 import 'package:analyzer/src/generated/sdk.dart'; 25 import 'package:analyzer/src/generated/sdk.dart';
23 import 'package:analyzer/src/generated/sdk_io.dart'; 26 import 'package:analyzer/src/generated/sdk_io.dart';
24 import 'package:args/args.dart'; 27 import 'package:args/args.dart';
25 28
26
27 /** 29 /**
28 * Initializes incremental logger. 30 * Initializes incremental logger.
29 * 31 *
30 * Supports following formats of [spec]: 32 * Supports following formats of [spec]:
31 * 33 *
32 * "console" - log to the console; 34 * "console" - log to the console;
33 * "file:/some/file/name" - log to the file, overwritten on start. 35 * "file:/some/file/name" - log to the file, overwritten on start.
34 */ 36 */
35 void _initIncrementalLogger(String spec) { 37 void _initIncrementalLogger(String spec) {
36 logger = NULL_LOGGER; 38 logger = NULL_LOGGER;
(...skipping 23 matching lines...) Expand all
60 * The name of the application that is used to start a server. 62 * The name of the application that is used to start a server.
61 */ 63 */
62 static const BINARY_NAME = "server"; 64 static const BINARY_NAME = "server";
63 65
64 /** 66 /**
65 * The name of the option used to set the identifier for the client. 67 * The name of the option used to set the identifier for the client.
66 */ 68 */
67 static const String CLIENT_ID = "client-id"; 69 static const String CLIENT_ID = "client-id";
68 70
69 /** 71 /**
72 * The name of the option used to set the version for the client.
73 */
74 static const String CLIENT_VERSION = "client-version";
75
76 /**
70 * The name of the option used to enable incremental resolution of API 77 * The name of the option used to enable incremental resolution of API
71 * changes. 78 * changes.
72 */ 79 */
73 static const String ENABLE_INCREMENTAL_RESOLUTION_API = 80 static const String ENABLE_INCREMENTAL_RESOLUTION_API =
74 "enable-incremental-resolution-api"; 81 "enable-incremental-resolution-api";
75 82
76 /** 83 /**
77 * The name of the option used to describe the incremental resolution logger. 84 * The name of the option used to describe the incremental resolution logger.
78 */ 85 */
79 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log"; 86 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log";
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (results[SDK_OPTION] != null) { 208 if (results[SDK_OPTION] != null) {
202 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); 209 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION]));
203 } else { 210 } else {
204 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, 211 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk,
205 // which will make a guess. 212 // which will make a guess.
206 defaultSdk = DirectoryBasedDartSdk.defaultSdk; 213 defaultSdk = DirectoryBasedDartSdk.defaultSdk;
207 } 214 }
208 215
209 InstrumentationService service = 216 InstrumentationService service =
210 new InstrumentationService(instrumentationServer); 217 new InstrumentationService(instrumentationServer);
211 // service.logVersion(results[CLIENT_ID], defaultSdk.sdkVersion); 218 service.logVersion(
219 _readUuid(service),
220 results[CLIENT_ID],
221 results[CLIENT_VERSION],
222 AnalysisServer.VERSION,
223 defaultSdk.sdkVersion);
212 AnalysisEngine.instance.instrumentationService = service; 224 AnalysisEngine.instance.instrumentationService = service;
213 // 225 //
214 // Process all of the plugins so that extensions are registered. 226 // Process all of the plugins so that extensions are registered.
215 // 227 //
216 ServerPlugin serverPlugin = new ServerPlugin(); 228 ServerPlugin serverPlugin = new ServerPlugin();
217 List<Plugin> plugins = <Plugin>[]; 229 List<Plugin> plugins = <Plugin>[];
218 plugins.add(serverPlugin); 230 plugins.add(serverPlugin);
219 plugins.addAll(_userDefinedPlugins); 231 plugins.addAll(_userDefinedPlugins);
220 ExtensionManager manager = new ExtensionManager(); 232 ExtensionManager manager = new ExtensionManager();
221 manager.processPlugins(plugins); 233 manager.processPlugins(plugins);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 283 }
272 284
273 /** 285 /**
274 * Create and return the parser used to parse the command-line arguments. 286 * Create and return the parser used to parse the command-line arguments.
275 */ 287 */
276 ArgParser _createArgParser() { 288 ArgParser _createArgParser() {
277 ArgParser parser = new ArgParser(); 289 ArgParser parser = new ArgParser();
278 parser.addOption( 290 parser.addOption(
279 CLIENT_ID, 291 CLIENT_ID,
280 help: "an identifier used to identify the client"); 292 help: "an identifier used to identify the client");
293 parser.addOption(CLIENT_VERSION, help: "the version of the client");
281 parser.addFlag( 294 parser.addFlag(
282 ENABLE_INCREMENTAL_RESOLUTION_API, 295 ENABLE_INCREMENTAL_RESOLUTION_API,
283 help: "enable using incremental resolution for API changes", 296 help: "enable using incremental resolution for API changes",
284 defaultsTo: false, 297 defaultsTo: false,
285 negatable: false); 298 negatable: false);
286 parser.addFlag( 299 parser.addFlag(
287 ENABLE_INSTRUMENTATION_OPTION, 300 ENABLE_INSTRUMENTATION_OPTION,
288 help: "enable sending instrumentation information to a server", 301 help: "enable sending instrumentation information to a server",
289 defaultsTo: false, 302 defaultsTo: false,
290 negatable: false); 303 negatable: false);
(...skipping 14 matching lines...) Expand all
305 INTERNAL_PRINT_TO_CONSOLE, 318 INTERNAL_PRINT_TO_CONSOLE,
306 help: "enable sending `print` output to the console", 319 help: "enable sending `print` output to the console",
307 defaultsTo: false, 320 defaultsTo: false,
308 negatable: false); 321 negatable: false);
309 parser.addOption( 322 parser.addOption(
310 PORT_OPTION, 323 PORT_OPTION,
311 help: "[port] the port on which the server will listen"); 324 help: "[port] the port on which the server will listen");
312 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk"); 325 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk");
313 parser.addFlag( 326 parser.addFlag(
314 NO_ERROR_NOTIFICATION, 327 NO_ERROR_NOTIFICATION,
315 help: 328 help: "disable sending all analysis error notifications to the server",
316 "disable sending all analysis error notifications to the server",
317 defaultsTo: false, 329 defaultsTo: false,
318 negatable: false); 330 negatable: false);
319 331
320 return parser; 332 return parser;
321 } 333 }
322 334
323 /** 335 /**
324 * Print information about how to use the server. 336 * Print information about how to use the server.
325 */ 337 */
326 void _printUsage(ArgParser parser) { 338 void _printUsage(ArgParser parser) {
327 print('Usage: $BINARY_NAME [flags]'); 339 print('Usage: $BINARY_NAME [flags]');
328 print(''); 340 print('');
329 print('Supported flags are:'); 341 print('Supported flags are:');
330 print(parser.usage); 342 print(parser.usage);
331 } 343 }
344
345 /**
346 * Read the UUID from disk, generating and storing a new one if necessary.
347 */
348 String _readUuid(InstrumentationService service) {
349 File uuidFile = new File(
350 PhysicalResourceProvider.INSTANCE.getStateLocation(
351 '.instrumentation').getChild('uuid.txt').path);
352 try {
353 if (uuidFile.existsSync()) {
354 String uuid = uuidFile.readAsStringSync();
355 if (uuid != null && uuid.length > 5) {
356 return uuid;
357 }
358 }
359 } catch (exception, stackTrace) {
360 service.logPriorityException(exception, stackTrace);
361 }
362 int millisecondsSinceEpoch = new DateTime.now().millisecondsSinceEpoch;
363 int random = new Random().nextInt(0x3fffffff);
364 String uuid = '$millisecondsSinceEpoch$random';
365 try {
366 uuidFile.parent.createSync(recursive: true);
367 uuidFile.writeAsStringSync(uuid);
368 } catch (exception, stackTrace) {
369 service.logPriorityException(exception, stackTrace);
370 // Slightly alter the uuid to indicate it was not persisted
371 uuid = 'temp-$uuid';
372 }
373 return uuid;
374 }
332 } 375 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_server.dart ('k') | pkg/analyzer/lib/instrumentation/instrumentation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698