04b178d8dc
Change-Id: If117a852bf052f9e3deb879cdd92c48b68241b26 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423161 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
51 lines
2.1 KiB
Dart
51 lines
2.1 KiB
Dart
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:analysis_server/src/analytics/percentile_calculator.dart';
|
|
|
|
/// Data about the requests that have been responded to that have the same
|
|
/// method.
|
|
class RequestData {
|
|
/// The name of the requests.
|
|
final String method;
|
|
|
|
/// The percentile calculator for latency times. The _latency time_ is the
|
|
/// time from when the client sent the request until the time the server
|
|
/// started processing the request.
|
|
final PercentileCalculator latencyTimes = PercentileCalculator();
|
|
|
|
/// The percentile calculator for response times. The _response time_ is the
|
|
/// time from when the server started processing the request until the time
|
|
/// the response was sent.
|
|
final PercentileCalculator responseTimes = PercentileCalculator();
|
|
|
|
/// A table mapping the names of fields in a request's parameters to the
|
|
/// percentile calculators related to the value of the parameter (such as the
|
|
/// length of a list).
|
|
final Map<String, PercentileCalculator> additionalPercentiles = {};
|
|
|
|
/// A table mapping the name of a field in a request's parameters and the name
|
|
/// of an enum constant to the number of times that the given constant was
|
|
/// used as the value of the field.
|
|
final Map<String, Map<String, int>> additionalEnumCounts = {};
|
|
|
|
/// Initialize a newly create data holder for requests with the given
|
|
/// [method].
|
|
RequestData(this.method);
|
|
|
|
/// Record the occurrence of the enum constant with the given [enumName] for
|
|
/// the field with the given [name].
|
|
void addEnumValue(String name, String enumName) {
|
|
var counts = additionalEnumCounts.putIfAbsent(name, () => {});
|
|
counts[enumName] = (counts[enumName] ?? 0) + 1;
|
|
}
|
|
|
|
/// Record a [value] for the field with the given [name].
|
|
void addValue(String name, int value) {
|
|
additionalPercentiles
|
|
.putIfAbsent(name, PercentileCalculator.new)
|
|
.addValue(value);
|
|
}
|
|
}
|