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

Unified 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: remove debugging code 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/server/driver.dart
diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
index 502b5d6d040f677f376050dc8bdb670d3788b238..3629e4721d51f36e200876aeaabe2fdf1e53335e 100644
--- a/pkg/analysis_server/lib/src/server/driver.dart
+++ b/pkg/analysis_server/lib/src/server/driver.dart
@@ -6,15 +6,18 @@ library driver;
import 'dart:async';
import 'dart:io';
+import 'dart:math';
import 'package:analysis_server/plugin/plugin.dart';
import 'package:analysis_server/src/analysis_server.dart';
+import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/plugin/plugin_impl.dart';
import 'package:analysis_server/src/plugin/server_plugin.dart';
import 'package:analysis_server/src/server/http_server.dart';
import 'package:analysis_server/src/server/stdio_server.dart';
import 'package:analysis_server/src/socket_server.dart';
import 'package:analysis_server/starter.dart';
+import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/incremental_logger.dart';
@@ -23,7 +26,6 @@ import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/sdk_io.dart';
import 'package:args/args.dart';
-
/**
* Initializes incremental logger.
*
@@ -67,6 +69,11 @@ class Driver implements ServerStarter {
static const String CLIENT_ID = "client-id";
/**
+ * The name of the option used to set the version for the client.
+ */
+ static const String CLIENT_VERSION = "client-version";
+
+ /**
* The name of the option used to enable incremental resolution of API
* changes.
*/
@@ -208,7 +215,12 @@ class Driver implements ServerStarter {
InstrumentationService service =
new InstrumentationService(instrumentationServer);
-// service.logVersion(results[CLIENT_ID], defaultSdk.sdkVersion);
+ service.logVersion(
+ _readUuid(service),
+ results[CLIENT_ID],
+ results[CLIENT_VERSION],
+ ANALYSIS_SERVER_VERSION,
+ defaultSdk.sdkVersion);
AnalysisEngine.instance.instrumentationService = service;
//
// Process all of the plugins so that extensions are registered.
@@ -278,6 +290,7 @@ class Driver implements ServerStarter {
parser.addOption(
CLIENT_ID,
help: "an identifier used to identify the client");
+ parser.addOption(CLIENT_VERSION, help: "the version of the client");
parser.addFlag(
ENABLE_INCREMENTAL_RESOLUTION_API,
help: "enable using incremental resolution for API changes",
@@ -312,8 +325,7 @@ class Driver implements ServerStarter {
parser.addOption(SDK_OPTION, help: "[path] the path to the sdk");
parser.addFlag(
NO_ERROR_NOTIFICATION,
- help:
- "disable sending all analysis error notifications to the server",
+ help: "disable sending all analysis error notifications to the server",
defaultsTo: false,
negatable: false);
@@ -329,4 +341,35 @@ class Driver implements ServerStarter {
print('Supported flags are:');
print(parser.usage);
}
+
+ /**
+ * Read the UUID from disk, generating and storing a new one if necessary.
+ */
+ String _readUuid(InstrumentationService service) {
+ File uuidFile = new File(
+ PhysicalResourceProvider.INSTANCE.getStateLocation(
+ '.instrumentation').getChild('uuid.txt').path);
danrubel 2015/01/16 18:54:12 Is this the correct location to cache the UUID ?
Brian Wilkerson 2015/01/16 19:48:28 I think so.
+ try {
+ if (uuidFile.existsSync()) {
+ String uuid = uuidFile.readAsStringSync();
+ if (uuid != null && uuid.length > 5) {
+ return uuid;
+ }
+ }
+ } catch (exception, stackTrace) {
+ service.logPriorityException(exception, stackTrace);
+ }
+ int millisecondsSinceEpoch = new DateTime.now().millisecondsSinceEpoch;
+ int random = new Random().nextInt(0x3fffffff);
+ String uuid = '$millisecondsSinceEpoch$random';
+ try {
+ uuidFile.parent.createSync(recursive: true);
+ uuidFile.writeAsStringSync(uuid);
+ } catch (exception, stackTrace) {
+ service.logPriorityException(exception, stackTrace);
+ // Slightly alter the uuid to indicate it was not persisted
+ uuid = 'temp-$uuid';
+ }
+ return uuid;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698