improve monitoring the solution

This commit is contained in:
Peter Maquiran
2024-07-30 15:52:07 +01:00
parent 8f0625eed4
commit edcaf951c2
11 changed files with 167 additions and 27 deletions
+2 -2
View File
@@ -103,7 +103,7 @@ import { calendarReducer } from './services/Repositorys/Agenda/agenda-memory-sou
import {MatMenuModule} from '@angular/material/menu';
import {MatIconModule} from '@angular/material/icon';
import { AngularCropperjsModule } from 'angular-cropperjs';
// import { ServiceWorkerModule } from '@angular/service-worker';
// import { AngularFireModule } from '@angular/fire';
// import { AngularFireMessagingModule } from '@angular/fire/messaging';
@@ -191,7 +191,7 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
ImageCropperModule,
MatMenuModule,
MatIconModule,
MatIconModule
],
entryComponents: [
DiplomaOptionsPage,
+44 -6
View File
@@ -144,7 +144,7 @@ export class ProfilePage implements OnInit {
return time;
}
@XTracerAsync({name:'profile/notificationClick', bugPrint: true, module:'notification'})
@XTracerAsync({name:'profile/notificationClick', bugPrint: true, module:'notification', autoFinish: false})
async notificatinsRoutes (index, item: NotificationTable, tracing?: TracingType) {
try {
@@ -152,7 +152,9 @@ export class ProfilePage implements OnInit {
this.isloading = true
if (item.service === "agenda") {
tracing.addEvent('start getEventById')
let res = await this.agendaDataRepository.getEventById(item.idObject, tracing)
tracing.addEvent('end getEventById')
if(item.idObject) {
@@ -168,9 +170,9 @@ export class ProfilePage implements OnInit {
this.deleteNotification(item);
tracing.setAttribute('outcome', 'success')
} else {
tracing.setAttribute('outcome', 'success')
tracing.setAttribute('data.exist', 'false')
tracing.setAttribute('data.exist', 'false')
tracing.setAttribute('outcome', 'success')
if (isHttpError(res.error)) {
if(res.error.status == 404) {
@@ -202,9 +204,10 @@ export class ProfilePage implements OnInit {
this.deleteNotification(item);
this.isloading = false
} else {
tracing.setAttribute('outcome', 'success')
console.log('evento não existe')
tracing.setAttribute('data.exist', 'false')
tracing.setAttribute('outcome', 'success')
this.objectRead[item.notificationId] = true
this.isloading = false
}
@@ -223,8 +226,11 @@ export class ProfilePage implements OnInit {
} else if (item.service === "gabinete-digital") {
this.isloading = true
tracing.addEvent('start getTask')
this.processesService.GetTask(item.idObject).subscribe((task) => {
tracing.addEvent('end getTask')
if (item.service === "gabinete-digital" && item.object === "expedientes") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', item.idObject, 'gabinete-digital']));
} else if (item.service === "gabinete-digital" && item.object === "despachos") {
@@ -258,9 +264,29 @@ export class ProfilePage implements OnInit {
this.deleteNotification(item);
this.isloading = false
tracing.setAttribute('outcome', 'success')
}, (error) => {
tracing.addEvent('end getTask')
tracing.log('gabinete notification not found', {
notificationObject: item
})
this.objectRead[item.notificationId] = true
this.isloading = false
if(isHttpError(error)) {
tracing.setAttribute('getTask.http.status.code', error.status?.toString())
if(error.status == 400) {
tracing.setAttribute('outcome', 'failed')
} else {
tracing.setAttribute('outcome', 'success')
}
} else {
tracing.setAttribute('outcome', 'failed')
}
})
@@ -268,10 +294,14 @@ export class ProfilePage implements OnInit {
if (item.service === "accoes" && item.idObject === "accao") {
this.zone.run(() => this.router.navigate(['/home/publications', item.idObject]));
this.deleteNotification(item);
tracing.setAttribute('outcome', 'success')
}
else if (item.service === "accoes" && item.idObject === "publicacao") {
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', item.folderId, item.idObject]));
this.deleteNotification(item);
tracing.setAttribute('outcome', 'success')
}
} else if (item.service === "chat") {
@@ -285,22 +315,30 @@ export class ProfilePage implements OnInit {
}, 200);
tracing.setAttribute('outcome', 'success')
this.deleteNotification(item);
} else {
console.log({service:item.service, Object, IdObject:item.idObject, FolderId:item.folderId})
tracing.log('click notification no route', {
notificationObject: item
})
tracing.setAttribute('notification.route', 'false')
tracing.setAttribute('outcome', 'failed')
tracing.setAttribute('parameters', JSON.stringify({Service:item.service, Object, IdObject:item.idObject, FolderId:item.folderId}))
tracing.setAttribute('outcome', 'failed')
}
} catch(error) {
console.log({service:item.service, Object, IdObject:item.idObject, FolderId: item.folderId})
tracing.setAttribute('outcome', 'failed')
tracing.log('click notification catch', {
notificationObject: item
})
tracing.setAttribute('parameters', JSON.stringify({service:item.service, Object, IdObject:item.idObject, FolderId:item.folderId}))
tracing.setAttribute('error', JSON.stringify(error))
tracing.setAttribute('outcome', 'failed')
}
@@ -9,7 +9,7 @@
<!-- Aside left -->
<div class="aside-wrapper d-flex flex-column width-md-40 flex-grow-1">
<ion-progress-bar type="indeterminate" *ngIf="TaskService.showLoaderNum != 0"></ion-progress-bar>
<ion-progress-bar type="indeterminate" *ngIf="skeletonLoader"></ion-progress-bar>
<div class="title-container">
<div class="title d-flex justify-center">
<ion-label *ngIf="hideRefreshBtn">Gabinete Digital</ion-label>
@@ -462,10 +462,10 @@ export class GabineteDigitalPage implements OnInit {
async loadAllProcesses() {
// this.skeletonLoader = true
await this.TaskService.LoadTask()
this.dynamicSearch()
// this.skeletonLoader = false
this.skeletonLoader = true
await this.TaskService.LoadTask();
this.dynamicSearch();
this.skeletonLoader = false
}
@@ -33,6 +33,11 @@ export function APIReturn(schema: z.ZodTypeAny, path: string) {
tracing?.setAttribute?.('map.error.schema-'+i, JSON.stringify(schema))
}
tracing.log('API return '+ path, {
data: result?.value,
issues: error?.errors
})
} else {
// Throw any other unexpected errors
// throw error;
@@ -74,6 +79,11 @@ export function APINODReturn(schema: z.ZodTypeAny, data , path: string, tracing?
tracing?.setAttribute('map.error.schema-'+i, JSON.stringify(schema))
}
tracing.log('API return '+ path, {
data,
issues: error?.errors
})
} else {
console.log(error)
// Throw any other unexpected errors
@@ -52,11 +52,13 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
}
const span = _tracerInstance.startSpan(name);
let finish = false
const data = {
event: {},
tags: {},
status: {} as any,
logs:[]
}
const returnObject = {
@@ -83,14 +85,22 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
if(key =='outcome' && value == 'failed') {
returnObject.hasError('error')
if(!autoFinish) {
returnObject.finish()
}
} else if (key =='outcome' && value == 'success') {
span.setStatus({code: SpanStatusCode.OK, message:name})
if(!autoFinish) {
returnObject.finish()
}
}
},
log(message: string, data: Object) {
log(message: string, dataObject: Object) {
const spanId = span.spanContext().spanId;
const _tracer = OpentelemetryLogging.getTracer('logging')
const spanContext = _tracer.startSpan(name)
data = convertAttributesToString(data)
dataObject = convertAttributesToString(dataObject)
if(environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
openTelemetryLogging.send({
@@ -99,7 +109,7 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
payload: {
message: message,
object: {
...data,
...dataObject,
spanId,
name,
user: SessionStore?.user?.FullName,
@@ -110,11 +120,15 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
})
}
data.logs.push(dataObject)
},
getAttribute: (key: string) => {
return data.tags[key]
},
finish: () => {
if(finish) return
if(environment.apiURL != 'https://gdqas-api.oapr.gov.ao/api/') {
span.end();
UseCaseCounter.add(1, {user: SessionStore?.user?.FullName, outcome:data.tags['outcome'] || data.status?.code , usecase: name})
@@ -123,6 +137,8 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
if(bugPrint && (data.tags['outcome'] == 'failed' || data.status?.code == SpanStatusCode.ERROR)) {
console.error(name, data)
}
finish = true
},
hasError:(message: string) => {
if(data.status?.code != SpanStatusCode.ERROR) {
+3 -5
View File
@@ -124,10 +124,9 @@ export class NotificationsService {
if (this.platform.is('ios')) {
FCM.getToken()
.then(r => {
tracing.setAttribute('notification.token', 'true')
this.postToken(r.token, geturl, tracing)
this.token = r.token
tracing.setAttribute('notification.token', 'true')
tracing.setAttribute('outcome', 'success')
// alert(this.token)
})
.catch(err => {
@@ -139,9 +138,10 @@ export class NotificationsService {
PushNotifications.addListener('registration',
(token: Token) => {
tracing.setAttribute('notification.token', 'true')
this.postToken(token.value, geturl, tracing)
this.token = token.value
tracing.setAttribute('notification.token', 'true')
}
);
@@ -157,13 +157,11 @@ export class NotificationsService {
this.token = token
tracing.setAttribute('notification.token', 'true')
tracing.setAttribute('outcome', 'success')
tracing.finish()
},
(error) => {
console.error('Permission denied:', error);
tracing.setAttribute('notification.token', 'false')
tracing.setAttribute('outcome', 'failed')
tracing.finish()
}
);
}