add monitoring

This commit is contained in:
Peter Maquiran
2024-06-18 09:14:22 +01:00
parent 157ecdd10b
commit 62c6afbe5b
19 changed files with 190 additions and 114 deletions
+16 -58
View File
@@ -17,6 +17,8 @@ import { RouteService } from 'src/app/services/route.service';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { isHttpError } from 'src/app/services/http.service';
@Component({
selector: 'app-view-event',
@@ -119,76 +121,32 @@ export class ViewEventPage implements OnInit {
ev.target.complete();
}
async loadEvent() {
@XTracerAsync({name:'ViewEventPage/loadEvent', log: false, bugPrint: true})
async loadEvent(tracing?: TracingType) {
const loader = this.toastService.loading();
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res;
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
// this.getFromDb();
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
}
loader.remove()
});
} else {
if(this.CalendarId) {
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
this.loadedEvent = res;
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
// this.getFromDb();
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
}
loader.remove()
});
} else {
}
}
let res = await this.agendaDataRepository.getEventById(this.eventId)
if(res.isOk()) {
tracing.setAttribute('outcome', 'success')
this.loadedEvent = res.value as any;
// this.addEventToDb(res);
loader.remove()
} else {
if (res.error.status === 0) {
// this.getFromDb();
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
tracing.setAttribute('eventId', this.eventId)
tracing.setAttribute('outcome', 'failed')
tracing.bugFlag()
if(!isHttpError(res.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #13')
} else if (isHttpError(res.error)) {
}
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
}
loader.remove()
}