Skip to content

Commit

Permalink
add support for tracing
Browse files Browse the repository at this point in the history
skin27 committed Mar 22, 2023
1 parent 0d90805 commit cc63603
Showing 10 changed files with 126 additions and 25 deletions.
Binary file modified ${activemq.data}/kahadb/db.data
Binary file not shown.
Binary file modified ${activemq.data}/kahadb/db.redo
Binary file not shown.
Binary file modified ${activemq.data}/kahadb/lock
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -270,11 +270,6 @@ <h4 class="modal-title">Edit Path</h4>
formControlName="componentType" id="field_component_type"
(change)="setTypeLinks(step, index, $event)"
style="text-align: left;"></ng-select>
<!--<ng-select *ngIf="editFlowForm['controls'].stepsData['controls'][index]['controls'].stepType.value==='ROUTER'"
[items]="producerComponentsNames" [clearable]="false"
formControlName="componentType" id="field_component_type"
(change)="setTypeLinks(step, index, $event)"
style="text-align: left;"></ng-select>-->
</div>


Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ export class FlowEditorEsbComponent implements OnInit, OnDestroy {

public logLevelListType = [
LogLevelType.OFF,
LogLevelType.ON,
LogLevelType.TRACE,
];

panelCollapsed: any = "uno";
@@ -1028,23 +1028,25 @@ export class FlowEditorEsbComponent implements OnInit, OnDestroy {

}

createOrEditMessage(step, formHeader: FormControl): void {
createOrEditMessage(step, formMessage: FormControl): void {

step.messageId = formHeader.value;
step.messageId = formMessage.value;

let modalRef;

if (typeof step.messageId === 'undefined' || step.messageId === null || !step.messageId) {
this.modalRefPromise = this.MessagePopupService.open(MessageDialogComponent as Component);
modalRef = this.MessagePopupService.open(MessageDialogComponent as Component);
}else{
this.modalRefPromise = this.MessagePopupService.open(MessageDialogComponent as Component, step.messageId);
modalRef = this.MessagePopupService.open(MessageDialogComponent as Component, step.messageId);
}

this.modalRefPromise.then(res => {
modalRef.then(res => {
res.result.then(
result => {
this.setMessage(step, result.id, formHeader);
this.setMessage(step, result.id, formMessage);
},
reason => {
this.setMessage(step, reason.id, formHeader);
this.setMessage(step, reason.id, formMessage);
}
);
},(reason)=>{
@@ -1053,16 +1055,16 @@ export class FlowEditorEsbComponent implements OnInit, OnDestroy {

}

setMessage(step, id, formHeader: FormControl): void {
this.messageService.getAllMessages().subscribe(
setMessage(step, id, formMessage: FormControl): void {

this.messageService
.getAllMessages()
.subscribe(
res => {
this.messages = res.body;
this.messageCreated = this.messages.length > 0;
step.messageId = id;

if (formHeader.value === null) {
formHeader.patchValue(id);
}
formMessage.patchValue(id);
step = null;
},
res => this.onError(res.body)
74 changes: 69 additions & 5 deletions src/main/webapp/app/entities/flow/flow-row.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Flow, IFlow } from 'app/shared/model/flow.model';
import { Flow, IFlow, LogLevelType } from 'app/shared/model/flow.model';
import { FlowService } from './flow.service';
import { FlowDeleteDialogComponent } from 'app/entities/flow/flow-delete-dialog.component';

import { Step, StepType } from 'app/shared/model/step.model';
import { StepService } from '../step/step.service';
import { IntegrationService } from "../integration/integration.service";
import { EventManager, EventWithContent } from 'app/core/util/event-manager.service';

import { Collectors } from 'app/shared/collect/collectors';

import { NavigationEnd, Router } from '@angular/router';
import dayjs from 'dayjs/esm';

@@ -74,6 +77,8 @@ export class FlowRowComponent implements OnInit, OnDestroy {
flowRowID: string;
flowRowErrorStepID: string;

filter: Filter;

statusMessage: any;

statsTableRows: Array<string> = [];
@@ -102,10 +107,12 @@ export class FlowRowComponent implements OnInit, OnDestroy {
constructor(
private flowService: FlowService,
private stepService: StepService,
private integrationService: IntegrationService,
private modalService: NgbModal,
private router: Router,
private eventManager: EventManager,
private webSocketsService: WebSocketsService
private webSocketsService: WebSocketsService,
private collectors: Collectors
) {

this.router.routeReuseStrategy.shouldReuseRoute = function () {
@@ -417,7 +424,6 @@ export class FlowRowComponent implements OnInit, OnDestroy {
}

exportFlow(){
console.log('export flow');
this.flowService.exportFlowConfiguration(this.flow);
}

@@ -458,8 +464,6 @@ export class FlowRowComponent implements OnInit, OnDestroy {

if (step.stepType === StepType.FROM || step.stepType === StepType.SOURCE) {
this.flowService.getFlowStats(flow.id, step.id, flow.integrationId).subscribe(res => {
console.log('4. get stats' + JSON.stringify(res.body));

this.setFlowStatistic(res.body, step.componentType.toString() + '://' + step.uri);
});
}else if(step.stepType === StepType.SCRIPT || step.stepType === StepType.ROUTE ){
@@ -744,12 +748,17 @@ export class FlowRowComponent implements OnInit, OnDestroy {
this.isFlowStatusOK = true;
this.disableActionBtns = true;

if(this.flow.logLevel === LogLevelType.TRACE){
this.enableTracing();
}

this.flowService.getConfiguration(this.flow.id).subscribe(
data => {
this.flowService.setConfiguration(this.flow.id, data.body, 'true').subscribe(data2 => {
this.flowService.start(this.flow.id).subscribe(
response => {
if (response.status === 200) {
// below is only used for tested (by default websockets is used)
// this.setFlowStatus('started');
}
this.disableActionBtns = false;
@@ -829,6 +838,10 @@ export class FlowRowComponent implements OnInit, OnDestroy {
this.isFlowStatusOK = true;
this.disableActionBtns = true;

if(this.flow.logLevel === LogLevelType.OFF){
this.disableTracing();
}

this.flowService.getConfiguration(this.flow.id).subscribe(
data => {
this.flowService.setConfiguration(this.flow.id, data.body, 'true').subscribe(data2 => {
@@ -860,6 +873,8 @@ export class FlowRowComponent implements OnInit, OnDestroy {
this.isFlowStatusOK = true;
this.disableActionBtns = true;

this.disableTracing();

this.flowService.stop(this.flow.id).subscribe(
response => {
if (response.status === 200) {
@@ -876,6 +891,45 @@ export class FlowRowComponent implements OnInit, OnDestroy {
);
}

enableTracing(){

const collector = this.collectors.tracing;
const sourceStep = this.steps.find(step => step.stepType === 'SOURCE');
const sinkStep = this.steps.find(step => step.stepType === 'SINK');
const sourceStepId = this.flow.id.toString() + '-' + sourceStep.id.toString();
const sinkStepId = this.flow.id.toString() + '-' + sinkStep.id.toString();

const filters: Array<any> = [];
filters.push(new Filter(sourceStepId,sourceStepId));
filters.push(new Filter(sinkStepId,sinkStepId));

collector.id = this.flow.id.toString();
collector.filters = filters;

this.integrationService.addCollector('1',collector.id,collector).subscribe(
response => {
//console.log('ok configured' + JSON.stringify(response));
},
err => {
console.log('Failed to configure tracing: ' + err);
}
);

}

disableTracing(){

this.integrationService.removeCollector('1',this.flow.id).subscribe(
response => {
//console.log('2. Removed' + response);
},
err => {
console.log('Failed to remove tracing: ' + JSON.stringify(err));
}
);

}

receive(): Subject<string> {
return this.listenerSubject;
}
@@ -930,3 +984,13 @@ export class FlowRowComponent implements OnInit, OnDestroy {
}

}

export class Filter {
id: string;
filter: string;

constructor(id: string, filter: string) {
this.id = id;
this.filter = filter;
}
}
1 change: 1 addition & 0 deletions src/main/webapp/app/entities/flow/flow.module.ts
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import { FlowService } from 'app/entities/flow/flow.service';

import { Components } from 'app/shared/camel/component-type';
import { Connections } from 'app/shared/camel/connections';
import { Collectors } from 'app/shared/collect/collectors';

const ENTITY_STATES = [...flowRoute];

12 changes: 12 additions & 0 deletions src/main/webapp/app/entities/integration/integration.service.ts
Original file line number Diff line number Diff line change
@@ -60,4 +60,16 @@ export class IntegrationService {
};
return this.http.post(`${this.resourceUrl}/${integrationid}/updatebackup/${frequency}`, url, options);
}

addCollector(integrationid, collectorid, collection){
const options = {
headers: new HttpHeaders({ observe: 'response', 'Content-Type': 'application/json', Accept: 'application/json' })
};
return this.http.post(`${this.integrationUrl}/${integrationid}/collector/${collectorid}/add`, collection, options);
}

removeCollector(integrationid, collectorid){
return this.http.delete(`${this.integrationUrl}/${integrationid}/collector/${collectorid}/remove`, { responseType: 'text' });
}

}
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ export class MessageDialogComponent implements OnInit {
} else {
const hk = new Header();
hk.type = this.typeHeader[0];
hk.type = this.languageHeader[0];
hk.language = this.languageHeader[0];
this.headers.push(hk);
this.message.id = cloneHeader ? null : this.message.id;
}
27 changes: 27 additions & 0 deletions src/main/webapp/app/shared/collect/collectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class Collectors {

tracing = {
"id": "0",
"type": "message",
"events": [
"ExchangeCompleted",
"ExchangeCreated",
"ExchangeFailed",
"ExchangeFailure",
"ExchangeFailureHandled",
"ExchangeFailureHandling",
],
"stores": [
{
"type": "console"
}
],
"filters": []
}

}

0 comments on commit cc63603

Please sign in to comment.