websocket admin connection to get query metric data
This commit is contained in:
parent
dc8b4b5252
commit
a6ed51b7a7
8 changed files with 104 additions and 29 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'package:lbry/src/load_generator.dart' as load;
|
||||
//import 'package:lbry/src/load_generator.dart' as load;
|
||||
import 'package:lbry/src/client.dart' as load;
|
||||
|
||||
main(List<String> arguments) {
|
||||
load.cli();
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export 'src/load_generator.dart' show LoadGenerator, LoadDataPoint;
|
||||
export 'src/client.dart' show Client, MetricDataPoint;
|
||||
|
|
|
@ -98,7 +98,7 @@ class LoadGenerator {
|
|||
}
|
||||
|
||||
class LoadDataPoint {
|
||||
final DateTime time = new DateTime.now();
|
||||
final DateTime time = DateTime.now();
|
||||
int success = 0;
|
||||
int errored = 0;
|
||||
int backlog = 0;
|
||||
|
|
|
@ -7,7 +7,7 @@ packages:
|
|||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.36.4"
|
||||
version: "0.37.0"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -63,14 +63,14 @@ packages:
|
|||
name: csslib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.16.0"
|
||||
version: "0.16.1"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.8"
|
||||
version: "1.2.9"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -84,7 +84,7 @@ packages:
|
|||
name: front_end
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.19"
|
||||
version: "0.1.20"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -134,20 +134,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.1+1"
|
||||
json_rpc_2:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_rpc_2
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
kernel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: kernel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.19"
|
||||
version: "0.3.20"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -210,7 +203,7 @@ packages:
|
|||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0+1"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -224,14 +217,14 @@ packages:
|
|||
name: protobuf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.12"
|
||||
version: "0.13.15"
|
||||
protoc_plugin:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: protoc_plugin
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "17.0.2"
|
||||
version: "17.0.4"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -302,6 +295,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
stream_transform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_transform
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.19"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -322,7 +322,7 @@ packages:
|
|||
name: test
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.4"
|
||||
version: "1.6.5"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -336,7 +336,7 @@ packages:
|
|||
name: test_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.6"
|
||||
version: "0.2.7"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -344,13 +344,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
vm_service_client:
|
||||
vm_service_lib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service_client
|
||||
name: vm_service_lib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.6+2"
|
||||
version: "3.22.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -359,12 +359,12 @@ packages:
|
|||
source: hosted
|
||||
version: "0.9.7+10"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: web_socket_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.13"
|
||||
version: "1.0.14"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -11,6 +11,7 @@ dependencies:
|
|||
http: ^0.12.0+2
|
||||
path: ^1.4.1
|
||||
protobuf: ^0.13.12
|
||||
web_socket_channel: ^1.0.4
|
||||
|
||||
dev_dependencies:
|
||||
pedantic: ^1.0.0
|
||||
|
|
|
@ -14,15 +14,55 @@ class SimpleTimeSeriesChart extends StatefulWidget {
|
|||
|
||||
|
||||
class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
||||
final List<MetricDataPoint> metricData = [];
|
||||
final List<LoadDataPoint> loadData = [];
|
||||
final List<charts.Series<LoadDataPoint, DateTime>> loadSeries = [];
|
||||
final List<charts.Series<LoadDataPoint, DateTime>> timeSeries = [];
|
||||
final List<charts.Series<MetricDataPoint, DateTime>> metricSeries = [];
|
||||
final List<charts.Series<MetricDataPoint, DateTime>> metricTimeSeries = [];
|
||||
final Random rand = Random();
|
||||
LoadGenerator loadGenerator;
|
||||
Client client;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
metricSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Searches',
|
||||
colorFn: (_, __) => charts.MaterialPalette.black.darker,
|
||||
domainFn: (MetricDataPoint load, _) => load.time,
|
||||
measureFn: (MetricDataPoint load, _) => load.search,
|
||||
data: metricData,
|
||||
)
|
||||
);
|
||||
metricSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Resolves',
|
||||
colorFn: (_, __) => charts.MaterialPalette.black.darker,
|
||||
domainFn: (MetricDataPoint load, _) => load.time,
|
||||
measureFn: (MetricDataPoint load, _) => load.resolve,
|
||||
data: metricData,
|
||||
)
|
||||
);
|
||||
metricTimeSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Avg. Resolve Time',
|
||||
colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault,
|
||||
domainFn: (MetricDataPoint load, _) => load.time,
|
||||
measureFn: (MetricDataPoint load, _) => load.avg_resolve,
|
||||
data: metricData,
|
||||
)
|
||||
);
|
||||
metricTimeSeries.add(
|
||||
charts.Series<MetricDataPoint, DateTime>(
|
||||
id: 'Avg. Search Time',
|
||||
colorFn: (_, __) => charts.MaterialPalette.yellow.shadeDefault,
|
||||
domainFn: (MetricDataPoint load, _) => load.time,
|
||||
measureFn: (MetricDataPoint load, _) => load.avg_search,
|
||||
data: metricData,
|
||||
)
|
||||
);
|
||||
loadSeries.add(
|
||||
charts.Series<LoadDataPoint, DateTime>(
|
||||
id: 'Load',
|
||||
|
@ -79,7 +119,7 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
);
|
||||
var increase = 1;
|
||||
loadData.add(LoadDataPoint());
|
||||
loadGenerator = LoadGenerator('spv2.lbry.com', 50001, {
|
||||
loadGenerator = LoadGenerator('localhost', 50001, {
|
||||
'id': 1,
|
||||
'method': 'blockchain.claimtrie.search',
|
||||
'params': {
|
||||
|
@ -99,17 +139,26 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
//if (loadData.length > 60) loadData.removeAt(0);
|
||||
loadData.add(stats);
|
||||
});
|
||||
//increase = max(1, min(30, (increase*1.1).ceil())-stats.backlog);
|
||||
increase += 1;
|
||||
increase = max(1, min(30, (increase*1.1).ceil())-stats.backlog);
|
||||
//increase += 1;
|
||||
//t.query['params']['offset'] = (increase/2).ceil()*t.query['params']['limit'];
|
||||
t.load = increase;//rand.nextInt(10)+5;
|
||||
return true;
|
||||
})..start();
|
||||
metricData.add(MetricDataPoint());
|
||||
client = Client('ws://localhost:8181/')..open()..metrics.listen((m) {
|
||||
setState(() {
|
||||
metricData.add(m);
|
||||
});
|
||||
print(m.avg_resolve);
|
||||
print(m.avg_search);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
loadGenerator.stop();
|
||||
if (client != null) client.close();
|
||||
if (loadGenerator != null) loadGenerator.stop();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -118,6 +167,8 @@ class _SimpleTimeSeriesChartState extends State<SimpleTimeSeriesChart> {
|
|||
return Column(children: <Widget>[
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(loadSeries)),
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(timeSeries)),
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(metricSeries)),
|
||||
SizedBox(height: 250.0, child: BetterTimeSeriesChart(metricTimeSeries)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ int main(int argc, char **argv) {
|
|||
flutter::FlutterWindowController flutter_controller(icu_data_path);
|
||||
|
||||
// Start the engine.
|
||||
if (!flutter_controller.CreateWindow(800, 600, "ver - lbry workbench",
|
||||
if (!flutter_controller.CreateWindow(800, 1200, "ver - lbry workbench",
|
||||
assets_path, arguments)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.11"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.6"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -205,5 +219,12 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.14"
|
||||
sdks:
|
||||
dart: ">=2.2.2 <3.0.0"
|
||||
|
|
Loading…
Reference in a new issue