Skip to content

Commit 856ad3b

Browse files
authored
Add more data to Event.analysisStatistics (#2219)
1 parent e0cc0bc commit 856ad3b

File tree

5 files changed

+126
-5
lines changed

5 files changed

+126
-5
lines changed

pkgs/unified_analytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 8.0.8
2+
- More data for `Event.analysisStatistics` for events from Dart Analysis Server.
3+
14
## 8.0.7
25
- Added optional fields `contextWorkspaceType` and `numberOfPackagesInWorkspace`
36
to `Event.contextStructure` for workspace and packages distribution from the

pkgs/unified_analytics/lib/src/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20);
8787
const String kLogFileName = 'dart-flutter-telemetry.log';
8888

8989
/// The current version of the package, should be in line with pubspec version.
90-
const String kPackageVersion = '8.0.7';
90+
const String kPackageVersion = '8.0.8';
9191

9292
/// The minimum length for a session.
9393
const int kSessionDurationMinutes = 30;

pkgs/unified_analytics/lib/src/event.dart

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,92 @@ final class Event {
108108
///
109109
/// [workingDuration] - json encoded percentile values indicating how long
110110
/// the analysis status was "working".
111+
/// [withFineDependencies] - whether the fine-grained feature is enabled.
112+
///
113+
/// Then there are three groups of measurements:
114+
/// * file modifications
115+
/// * workspace shape
116+
/// * background analysis
117+
///
118+
/// The file modifications group includes:
119+
/// [changedFileEventCount] - the number of file change events received.
120+
/// [removedFileEventCount] - the number of file removal events received.
121+
/// [changedFileUniqueCount] - the number of unique files that were changed.
122+
/// [removedFileUniqueCount] - the number of unique files that were removed.
123+
///
124+
/// The workspace shape group includes:
125+
/// * [immediateFileCountPercentiles] - json encoded percentile values for the
126+
/// number of files in the immediate workspace.
127+
/// * [immediateFileLineCountPercentiles] - json encoded percentile values for
128+
/// the number of lines in the immediate workspace files.
129+
/// * [transitiveFileCountPercentiles] - json encoded percentile values for
130+
/// the number of files in the transitive workspace.
131+
/// * [transitiveFileLineCountPercentiles] - json encoded percentile values
132+
/// for the number of lines in the transitive workspace files.
133+
///
134+
/// This allows us to understand how big is the workspace, and how it changed
135+
/// over the reported period.
136+
///
137+
/// The background analysis group includes:
138+
/// * [produceErrorsPotentialFileCount] - the total number of files for which
139+
/// the reported diagnostics could potentially change.
140+
/// * [produceErrorsPotentialFileLineCount] - the total number of lines in
141+
/// files for which the reported diagnostics could potentially change.
142+
/// * [produceErrorsActualFileCount] - the total number of files that actually
143+
/// were analyzed during background analysis.
144+
/// * [produceErrorsActualFileLineCount] - the total number of lines in files
145+
/// that actually were analyzed during background analysis.
146+
/// * [produceErrorsDurationMs] - the total duration in milliseconds for
147+
/// producing diagnostics.
148+
/// * [produceErrorsElementsDurationMs] - the total duration in milliseconds
149+
/// for preparing elements before analysis.
150+
///
151+
/// This allows us to understand how many files were scheduled for analysis,
152+
/// and how many of these files are served from the cache, because we
153+
/// determined that the change that caused them to be scheduled for analysis
154+
/// actually does not affect resolution and the set of diagnostics, e.g.
155+
/// because the change was in a method body, or to an API that does not
156+
/// affect this specific file (if fine-grained dependencies enabled).
111157
Event.analysisStatistics({
112158
required String workingDuration,
159+
required bool withFineDependencies,
160+
required int changedFileEventCount,
161+
required int removedFileEventCount,
162+
required int changedFileUniqueCount,
163+
required int removedFileUniqueCount,
164+
required String immediateFileCountPercentiles,
165+
required String immediateFileLineCountPercentiles,
166+
required String transitiveFileCountPercentiles,
167+
required String transitiveFileLineCountPercentiles,
168+
required int produceErrorsPotentialFileCount,
169+
required int produceErrorsPotentialFileLineCount,
170+
required int produceErrorsActualFileCount,
171+
required int produceErrorsActualFileLineCount,
172+
required int produceErrorsDurationMs,
173+
required int produceErrorsElementsDurationMs,
113174
}) : this._(
114175
eventName: DashEvent.analysisStatistics,
115176
eventData: {
116177
'workingDuration': workingDuration,
178+
'withFineDependencies': withFineDependencies,
179+
'changedFileUniqueCount': changedFileUniqueCount,
180+
'removedFileUniqueCount': removedFileUniqueCount,
181+
'changedFileEventCount': changedFileEventCount,
182+
'removedFileEventCount': removedFileEventCount,
183+
'immediateFileCountPercentiles': immediateFileCountPercentiles,
184+
'immediateFileLineCountPercentiles':
185+
immediateFileLineCountPercentiles,
186+
'transitiveFileCountPercentiles': transitiveFileCountPercentiles,
187+
'transitiveFileLineCountPercentiles':
188+
transitiveFileLineCountPercentiles,
189+
'produceErrorsPotentialFileCount': produceErrorsPotentialFileCount,
190+
'produceErrorsPotentialFileLineCount':
191+
produceErrorsPotentialFileLineCount,
192+
'produceErrorsActualFileCount': produceErrorsActualFileCount,
193+
'produceErrorsActualFileLineCount':
194+
produceErrorsActualFileLineCount,
195+
'produceErrorsDurationMs': produceErrorsDurationMs,
196+
'produceErrorsElementsDurationMs': produceErrorsElementsDurationMs,
117197
},
118198
);
119199

pkgs/unified_analytics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: >-
55
# LINT.IfChange
66
# When updating this, keep the version consistent with the changelog and the
77
# value in lib/src/constants.dart.
8-
version: 8.0.7
8+
version: 8.0.8
99
# LINT.ThenChange(lib/src/constants.dart)
1010
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
1111
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics

pkgs/unified_analytics/test/event_test.dart

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,53 @@ import 'package:unified_analytics/unified_analytics.dart';
1111

1212
void main() {
1313
test('Event.analysisStatistics constructed', () {
14-
Event generateEvent() =>
15-
Event.analysisStatistics(workingDuration: 'workingDuration');
14+
Event generateEvent() => Event.analysisStatistics(
15+
workingDuration: 'workingDuration',
16+
withFineDependencies: false,
17+
changedFileEventCount: 1,
18+
removedFileEventCount: 2,
19+
changedFileUniqueCount: 3,
20+
removedFileUniqueCount: 4,
21+
immediateFileCountPercentiles: 'immediateFileCountPercentiles',
22+
immediateFileLineCountPercentiles:
23+
'immediateFileLineCountPercentiles',
24+
transitiveFileCountPercentiles: 'transitiveFileCountPercentiles',
25+
transitiveFileLineCountPercentiles:
26+
'transitiveFileLineCountPercentiles',
27+
produceErrorsPotentialFileCount: 10,
28+
produceErrorsPotentialFileLineCount: 11,
29+
produceErrorsActualFileCount: 12,
30+
produceErrorsActualFileLineCount: 13,
31+
produceErrorsDurationMs: 14,
32+
produceErrorsElementsDurationMs: 15,
33+
);
1634

1735
final constructedEvent = generateEvent();
1836

1937
expect(generateEvent, returnsNormally);
2038
expect(constructedEvent.eventName, DashEvent.analysisStatistics);
2139
expect(constructedEvent.eventData['workingDuration'], 'workingDuration');
22-
expect(constructedEvent.eventData.length, 1);
40+
expect(constructedEvent.eventData['withFineDependencies'], false);
41+
expect(constructedEvent.eventData['changedFileEventCount'], 1);
42+
expect(constructedEvent.eventData['removedFileEventCount'], 2);
43+
expect(constructedEvent.eventData['changedFileUniqueCount'], 3);
44+
expect(constructedEvent.eventData['removedFileUniqueCount'], 4);
45+
expect(constructedEvent.eventData['immediateFileCountPercentiles'],
46+
'immediateFileCountPercentiles');
47+
expect(constructedEvent.eventData['immediateFileLineCountPercentiles'],
48+
'immediateFileLineCountPercentiles');
49+
expect(constructedEvent.eventData['transitiveFileCountPercentiles'],
50+
'transitiveFileCountPercentiles');
51+
expect(constructedEvent.eventData['transitiveFileLineCountPercentiles'],
52+
'transitiveFileLineCountPercentiles');
53+
expect(constructedEvent.eventData['produceErrorsPotentialFileCount'], 10);
54+
expect(
55+
constructedEvent.eventData['produceErrorsPotentialFileLineCount'], 11);
56+
expect(constructedEvent.eventData['produceErrorsActualFileCount'], 12);
57+
expect(constructedEvent.eventData['produceErrorsActualFileLineCount'], 13);
58+
expect(constructedEvent.eventData['produceErrorsDurationMs'], 14);
59+
expect(constructedEvent.eventData['produceErrorsElementsDurationMs'], 15);
60+
expect(constructedEvent.eventData.length, 16);
2361
});
2462

2563
test('Event.analyticsCollectionEnabled constructed', () {

0 commit comments

Comments
 (0)