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

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

Issue 2963323002: Add analytics to analyzer-cli and analysis server. (Closed)
Patch Set: suppress analytics for integration tests; update the gn files Created 3 years, 5 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
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:core'; 7 import 'dart:core';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 import 'dart:math' show max; 9 import 'dart:math' show max;
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 import 'package:analyzer/src/generated/sdk.dart'; 54 import 'package:analyzer/src/generated/sdk.dart';
55 import 'package:analyzer/src/generated/source.dart'; 55 import 'package:analyzer/src/generated/source.dart';
56 import 'package:analyzer/src/generated/source_io.dart'; 56 import 'package:analyzer/src/generated/source_io.dart';
57 import 'package:analyzer/src/generated/utilities_general.dart'; 57 import 'package:analyzer/src/generated/utilities_general.dart';
58 import 'package:analyzer/src/util/glob.dart'; 58 import 'package:analyzer/src/util/glob.dart';
59 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element; 59 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element;
60 import 'package:front_end/src/base/performace_logger.dart'; 60 import 'package:front_end/src/base/performace_logger.dart';
61 import 'package:front_end/src/incremental/byte_store.dart'; 61 import 'package:front_end/src/incremental/byte_store.dart';
62 import 'package:front_end/src/incremental/file_byte_store.dart'; 62 import 'package:front_end/src/incremental/file_byte_store.dart';
63 import 'package:plugin/plugin.dart'; 63 import 'package:plugin/plugin.dart';
64 import 'package:telemetry/crash_reporting.dart';
65 import 'package:telemetry/telemetry.dart' as telemetry;
66 import 'package:usage/usage.dart';
64 import 'package:watcher/watcher.dart'; 67 import 'package:watcher/watcher.dart';
65 68
66 typedef void OptionUpdater(AnalysisOptionsImpl options); 69 typedef void OptionUpdater(AnalysisOptionsImpl options);
67 70
68 /** 71 /**
69 * Enum representing reasons why analysis might be done for a given file. 72 * Enum representing reasons why analysis might be done for a given file.
70 */ 73 */
71 class AnalysisDoneReason { 74 class AnalysisDoneReason {
72 /** 75 /**
73 * Analysis of the file completed successfully. 76 * Analysis of the file completed successfully.
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 stackTrace = StackTrace.current; 774 stackTrace = StackTrace.current;
772 buffer.writeln(); 775 buffer.writeln();
773 buffer.write(stackTrace); 776 buffer.write(stackTrace);
774 } 777 }
775 778
776 // send the notification 779 // send the notification
777 channel.sendNotification( 780 channel.sendNotification(
778 new ServerErrorParams(fatal, message, buffer.toString()) 781 new ServerErrorParams(fatal, message, buffer.toString())
779 .toNotification()); 782 .toNotification());
780 783
784 // send to crash reporting
785 options.crashReportSender.sendReport(exception, stackTrace: stackTrace);
786
781 // remember the last few exceptions 787 // remember the last few exceptions
782 if (exception is CaughtException) { 788 if (exception is CaughtException) {
783 stackTrace ??= exception.stackTrace; 789 stackTrace ??= exception.stackTrace;
784 } 790 }
785 exceptions.add(new ServerException(message, exception, stackTrace, fatal)); 791 exceptions.add(new ServerException(message, exception, stackTrace, fatal));
786 } 792 }
787 793
788 /** 794 /**
789 * Send status notification to the client. The state of analysis is given by 795 * Send status notification to the client. The state of analysis is given by
790 * the [status] information. 796 * the [status] information.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 903 }
898 904
899 /** 905 /**
900 * Returns `true` if errors should be reported for [file] with the given 906 * Returns `true` if errors should be reported for [file] with the given
901 * absolute path. 907 * absolute path.
902 */ 908 */
903 bool shouldSendErrorsNotificationFor(String file) { 909 bool shouldSendErrorsNotificationFor(String file) {
904 return contextManager.isInAnalysisRoot(file); 910 return contextManager.isInAnalysisRoot(file);
905 } 911 }
906 912
907 void shutdown() { 913 Future shutdown() async {
scheglov 2017/06/30 23:36:29 Future<Null>
devoncarew 2017/07/01 22:18:04 Done.
908 running = false; 914 running = false;
909 // Defer closing the channel and shutting down the instrumentation server so 915 // Defer closing the channel and shutting down the instrumentation server so
910 // that the shutdown response can be sent and logged. 916 // that the shutdown response can be sent and logged.
911 new Future(() { 917 await new Future(() {
Brian Wilkerson 2017/06/30 22:52:17 We don't currently wait. Are you sure we should?
devoncarew 2017/07/01 22:18:04 I've removed the await (and added the ability to c
912 instrumentationService.shutdown(); 918 instrumentationService.shutdown();
913 channel.close(); 919 channel.close();
914 }); 920 });
921
922 // TODO(devoncarew): Call exit() explicitly?
923 await options.analytics
924 .waitForLastPing(timeout: new Duration(milliseconds: 200));
915 } 925 }
916 926
917 /** 927 /**
918 * Implementation for `analysis.updateContent`. 928 * Implementation for `analysis.updateContent`.
919 */ 929 */
920 void updateContent(String id, Map<String, dynamic> changes) { 930 void updateContent(String id, Map<String, dynamic> changes) {
921 changes.forEach((file, change) { 931 changes.forEach((file, change) {
922 // Prepare the new contents. 932 // Prepare the new contents.
923 String oldContents = fileContentOverlay[file]; 933 String oldContents = fileContentOverlay[file];
924 String newContents; 934 String newContents;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1054 }
1045 1055
1046 class AnalysisServerOptions { 1056 class AnalysisServerOptions {
1047 bool useAnalysisHighlight2 = false; 1057 bool useAnalysisHighlight2 = false;
1048 String fileReadMode = 'as-is'; 1058 String fileReadMode = 'as-is';
1049 String newAnalysisDriverLog; 1059 String newAnalysisDriverLog;
1050 1060
1051 String clientId; 1061 String clientId;
1052 String clientVersion; 1062 String clientVersion;
1053 1063
1064 telemetry.Analytics analytics;
1065 CrashReportSender crashReportSender;
1066
1054 // IDE options 1067 // IDE options
1055 bool enableVerboseFlutterCompletions = false; 1068 bool enableVerboseFlutterCompletions = false;
1069
1070 void addMocks() {
scheglov 2017/06/30 23:36:29 Do we create and assign these objects just to avoi
devoncarew 2017/07/01 22:18:04 I removed this method, and instead had all the pla
1071 analytics = new AnalyticsMock()..enabled = false;
1072 crashReportSender = new CrashReportSender('mock-crash-id', analytics);
1073 }
1056 } 1074 }
1057 1075
1058 /** 1076 /**
1059 * A [PriorityChangeEvent] indicates the set the priority files has changed. 1077 * A [PriorityChangeEvent] indicates the set the priority files has changed.
1060 */ 1078 */
1061 class PriorityChangeEvent { 1079 class PriorityChangeEvent {
1062 final Source firstSource; 1080 final Source firstSource;
1063 1081
1064 PriorityChangeEvent(this.firstSource); 1082 PriorityChangeEvent(this.firstSource);
1065 } 1083 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 /** 1483 /**
1466 * The [PerformanceTag] for time spent in server request handlers. 1484 * The [PerformanceTag] for time spent in server request handlers.
1467 */ 1485 */
1468 static PerformanceTag serverRequests = server.createChild('requests'); 1486 static PerformanceTag serverRequests = server.createChild('requests');
1469 1487
1470 /** 1488 /**
1471 * The [PerformanceTag] for time spent in split store microtasks. 1489 * The [PerformanceTag] for time spent in split store microtasks.
1472 */ 1490 */
1473 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 1491 static PerformanceTag splitStore = new PerformanceTag('splitStore');
1474 } 1492 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698