Skip to content

Commit c096c9a

Browse files
committed
GUI BugFix => Combine metrics in pairs: use component to get metrics correctly
1 parent be2167b commit c096c9a

File tree

1 file changed

+46
-24
lines changed

1 file changed

+46
-24
lines changed

elastest-torm-gui/src/app/elastest-etm/etm-monitoring-view/etm-chart-group/etm-chart-group.component.ts

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
7878
ngOnInit(): void {}
7979

8080
ngAfterViewInit(): void {
81-
this.metricsChartCardComponents.changes.subscribe((data) => this.subscribeAllToEvents());
81+
this.metricsChartCardComponents.changes.subscribe(data => this.subscribeAllToEvents());
8282
if (this.live) {
8383
this.initObservables();
8484
}
@@ -96,7 +96,7 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
9696
subjectMap.forEach((obs: Subject<string>, key: string) => {
9797
let subjectData: any = this.elastestRabbitmqService.getDataFromSubjectName(key);
9898
if (subjectData.streamType === 'composed_metrics' || subjectData.streamType === 'atomic_metric') {
99-
obs.subscribe((data) => this.updateDefaultChartsData(data));
99+
obs.subscribe(data => this.updateDefaultChartsData(data));
100100
}
101101
});
102102
}
@@ -211,7 +211,8 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
211211
// Else, is a custom metric
212212
let pos: number = this.initCustomMetric(metric, individualMetrics);
213213
if (!this.live && pos >= 0) {
214-
let metricName: string = metric.streamType === 'atomic_metric' ? metric.etType : metric.etType + '.' + metric.subtype;
214+
let metricName: string =
215+
metric.streamType === 'atomic_metric' ? metric.etType : metric.etType + '.' + metric.subtype;
215216
this.monitoringService
216217
.searchAllDynamic(
217218
individualMetrics.monitoringIndex,
@@ -335,7 +336,10 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
335336

336337
initializeBasicAttrByMetric(metric: MetricsFieldModel): ESRabComplexMetricsModel {
337338
let ignoreComponent: string = this.getIgnoreComponent();
338-
let individualMetrics: ESRabComplexMetricsModel = new ESRabComplexMetricsModel(this.monitoringService, ignoreComponent);
339+
let individualMetrics: ESRabComplexMetricsModel = new ESRabComplexMetricsModel(
340+
this.monitoringService,
341+
ignoreComponent,
342+
);
339343
individualMetrics.metric = metric;
340344
individualMetrics.name = this.createName(metric.component, metric.stream, metric.etType, metric.subtype);
341345
individualMetrics.component = metric.component;
@@ -358,7 +362,10 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
358362
addMoreMetricsFromMetricPair(metricsPairForCombo: MetricsFieldModel[]): boolean {
359363
if (metricsPairForCombo) {
360364
let ignoreComponent: string = this.getIgnoreComponent();
361-
let comboPairChart: ESRabComplexMetricsModel = new ESRabComplexMetricsModel(this.monitoringService, ignoreComponent);
365+
let comboPairChart: ESRabComplexMetricsModel = new ESRabComplexMetricsModel(
366+
this.monitoringService,
367+
ignoreComponent,
368+
);
362369
comboPairChart.isCombinedPair = true;
363370
comboPairChart.startDate = this.startDate;
364371
comboPairChart.endDate = this.endDate;
@@ -414,7 +421,13 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
414421
// Get data of second metric
415422
this.monitoringService.getMetricUnit(monitoringIndex, secondMetric).subscribe(
416423
(secondMetricUnit2: Units | string) => {
417-
this.initMetricPairChart(firstMetric, secondMetric, firstMetricUnit2, secondMetricUnit2, comboPairChart);
424+
this.initMetricPairChart(
425+
firstMetric,
426+
secondMetric,
427+
firstMetricUnit2,
428+
secondMetricUnit2,
429+
comboPairChart,
430+
);
418431
},
419432
(error: Error) => console.error('Could not load more metric pair (second metric): ' + error),
420433
);
@@ -439,15 +452,15 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
439452

440453
comboPairChart.allMetricsFields.addMetricsFieldToList(
441454
firstMetric,
442-
comboPairChart.component,
455+
firstMetric.component,
443456
comboPairChart.stream,
444457
firstMetric.streamType,
445458
firstMetric.activated,
446459
);
447460

448461
comboPairChart.allMetricsFields.addMetricsFieldToList(
449462
secondMetric,
450-
comboPairChart.component,
463+
secondMetric.component,
451464
comboPairChart.stream,
452465
secondMetric.streamType,
453466
secondMetric.activated,
@@ -480,21 +493,23 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
480493
this.elastestRabbitmqService.createSubject(metric.streamType, metric.component, metric.stream);
481494
let index: string = this.getAbstractTJobExecIndex(metric.component);
482495

483-
this.elastestRabbitmqService.createAndSubscribeToTopic(index, metric.streamType, metric.component, metric.stream).subscribe(
484-
(data: any) => {
485-
if (data['et_type'] === metric.etType && data.component === metric.component) {
486-
let parsedData: SingleMetricModel = this.monitoringService.convertToMetricTrace(data, metric);
487-
if (parsedData === undefined) {
488-
console.error('Undefined data received, not added to ' + metric.name);
489-
} else {
490-
if (this.chartsList[pos]) {
491-
this.chartsList[pos].addDataToSimpleMetricByGivenList(listName, metric, [parsedData]);
496+
this.elastestRabbitmqService
497+
.createAndSubscribeToTopic(index, metric.streamType, metric.component, metric.stream)
498+
.subscribe(
499+
(data: any) => {
500+
if (data['et_type'] === metric.etType && data.component === metric.component) {
501+
let parsedData: SingleMetricModel = this.monitoringService.convertToMetricTrace(data, metric);
502+
if (parsedData === undefined) {
503+
console.error('Undefined data received, not added to ' + metric.name);
504+
} else {
505+
if (this.chartsList[pos]) {
506+
this.chartsList[pos].addDataToSimpleMetricByGivenList(listName, metric, [parsedData]);
507+
}
492508
}
493509
}
494-
}
495-
},
496-
(error: Error) => console.log(error),
497-
);
510+
},
511+
(error: Error) => console.log(error),
512+
);
498513
}
499514

500515
createSubjectAndSubscribe(component: string, stream: string, streamType: string): void {
@@ -537,7 +552,10 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
537552

538553
createGroupedMetricList(): void {
539554
let defaultGroupNum: number = 3;
540-
this.groupedMetricsList = this.createGroupedArray(this.chartsList.concat(this.combinedPairChartsList), defaultGroupNum);
555+
this.groupedMetricsList = this.createGroupedArray(
556+
this.chartsList.concat(this.combinedPairChartsList),
557+
defaultGroupNum,
558+
);
541559
}
542560

543561
createGroupedArray(arr: any[], chunkSize: number): any[] {
@@ -569,7 +587,8 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
569587
// If not is live, subscribe to events
570588
this.unsubscribeAllEvents();
571589
this.loaded =
572-
this.metricsChartCardComponents.toArray() && this.metricsChartCardComponents.toArray().length === this.chartsList.length;
590+
this.metricsChartCardComponents.toArray() &&
591+
this.metricsChartCardComponents.toArray().length === this.chartsList.length;
573592
if (this.loaded) {
574593
this.metricsChartCardComponents.forEach((element: MetricsChartCardComponent) => {
575594
this.subscribeToEvents(element);
@@ -659,7 +678,10 @@ export class EtmChartGroupComponent implements OnInit, AfterViewInit, AfterViewC
659678

660679
removeAndUnsubscribe(metric: ESRabComplexMetricsModel): void {
661680
if (metric) {
662-
this.removeAndUnsubscribeByNameAndList(metric.name, metric.isCombinedPair ? this.combinedPairChartsList : this.chartsList);
681+
this.removeAndUnsubscribeByNameAndList(
682+
metric.name,
683+
metric.isCombinedPair ? this.combinedPairChartsList : this.chartsList,
684+
);
663685
}
664686
}
665687

0 commit comments

Comments
 (0)