add telemetry

This commit is contained in:
Peter Maquiran
2024-10-29 16:00:19 +01:00
parent 0c6fa3118e
commit eedb66a1cf
11 changed files with 110 additions and 34 deletions
+1
View File
@@ -0,0 +1 @@
api/Tasks/ListKnowledge?ProcessName=Expediente&OnlyCount=false&pageNum=1&pageSize=25&status=3
@@ -1,10 +1,8 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { object, z } from 'zod'; import { z } from 'zod';
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
import { MessageRemoteDataSourceService } from '../../../../module/chat/data/repository/message/message-remote-data-source.service';
import { MessageSocketRepositoryService } from '../../../../module/chat/data/repository/message/message-live-signalr-data-source.service';
import { IMessageSocketRepository } from '../../repository/message/message-socket-repository'; import { IMessageSocketRepository } from '../../repository/message/message-socket-repository';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { zodSafeValidation } from 'src/app/utils/zodValidation';
const MessageReactionInputDTOSchema = z.object({ const MessageReactionInputDTOSchema = z.object({
memberId: z.number(), memberId: z.number(),
@@ -25,8 +23,23 @@ export class MessageReactionUseCaseService {
public repository: IMessageSocketRepository public repository: IMessageSocketRepository
) { } ) { }
@ValidateSchema(MessageReactionInputDTOSchema) @XTracerAsync({name:'MessageReactionUseCaseService', module:'chat', bugPrint: true, waitNThrow: 5000})
execute(input: MessageReactionInput) { async execute(input: MessageReactionInput, tracing?: TracingType) {
return this.repository.reactToMessageSocket(input)
const validation = zodSafeValidation<MessageReactionInput>(MessageReactionInputDTOSchema, input)
if(validation.isOk()) {
const result = await this.repository.reactToMessageSocket(input)
// console.log('result', result)
return result
} else {
tracing.hasError('invalid input', {
error: validation.error
})
}
} }
} }
@@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { FirebasePushNotificationService } from 'src/app/module/notification/data/datasource/firebase-push-notification.service';
import { NotificationLive } from 'src/app/module/notification/data/dto/NotificationLiveOutputDTO';
import { NotificationMapper } from 'src/app/module/notification/domain/mapper/notificationMapper';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import {
SpanStatus, SpanStatusCode
} from '@opentelemetry/api';
@Injectable({
providedIn: 'root'
})
export class NotificationReceiveService {
constructor(
private FirebasePushNotificationService: FirebasePushNotificationService,
) { }
@XTracerAsync({name:'NotificationReceiveService', module:'notification', bugPrint: true})
async execute(func:Function,tracing?: TracingType) {
const notificationSubject: Subject<NotificationLive> = new Subject<NotificationLive>();
this.FirebasePushNotificationService.onReceiveForeground(async (data)=> {
try {
func(NotificationMapper(data));
} catch (error) {
const NewTracing = tracing.newTracer({name:'NotificationReceiveService-item-error'})
NewTracing.setAttribute('notification-item-error', 'true')
NewTracing.hasError('NotificationMapper', {
notificationData: data
})
NewTracing.log('invalid notification', data);
NewTracing.finish()
}
})
return notificationSubject
}
}
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable, Subject, timer } from 'rxjs'; import { BehaviorSubject, Observable, Subject, timer } from 'rxjs';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { SignalRConnection, SocketMessage } from './signalR'; import { SignalRConnection } from './signalR';
import { Plugins } from '@capacitor/core'; import { Plugins } from '@capacitor/core';
import { switchMap } from 'rxjs/operators'; import { switchMap } from 'rxjs/operators';
import { err, Result } from 'neverthrow'; import { err, Result } from 'neverthrow';
@@ -11,7 +11,7 @@ import { MessageCreateOutPutDataDTO, MessageInputDTO } from '../../../../../core
import { MessageMarkAsReadInput } from '../../../../../core/chat/usecase/message/message-mark-as-read-use-case.service'; import { MessageMarkAsReadInput } from '../../../../../core/chat/usecase/message/message-mark-as-read-use-case.service';
import { MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO'; import { MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
import { MessageDeleteInputDTO } from '../../../../../core/chat/usecase/message/message-delete-by-id-live-use-case.service'; import { MessageDeleteInputDTO } from '../../../../../core/chat/usecase/message/message-delete-by-id-live-use-case.service';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
interface sendDeliverAt { interface sendDeliverAt {
memberId: number, memberId: number,
@@ -140,13 +140,17 @@ export class MessageSocketRepositoryService implements IMessageSocketRepository
reactToMessageSocket(data: MessageReactionInput) { reactToMessageSocket(data: MessageReactionInput) {
this.socket.sendData({ data['requestId'] = InstanceId +'@'+ uuidv4();
return this.socket.sendData({
method: 'ReactMessage', method: 'ReactMessage',
data data
}) })
} }
updateMessage(input: MessageUpdateInput) { updateMessage(input: MessageUpdateInput) {
input['requestId'] = InstanceId +'@'+ uuidv4();
this.socket.sendData({ this.socket.sendData({
method: 'EditMessage', method: 'EditMessage',
data: input, data: input,
@@ -2,12 +2,12 @@ import { Injectable } from '@angular/core';
import { liveQuery } from 'Dexie'; import { liveQuery } from 'Dexie';
import { MessageEntity } from '../../../../../core/chat/entity/message'; import { MessageEntity } from '../../../../../core/chat/entity/message';
import { DexieRepository } from 'src/app/infra/repository/dexie/dexie-repository.service'; import { DexieRepository } from 'src/app/infra/repository/dexie/dexie-repository.service';
import { Observable as DexieObservable, PromiseExtended } from 'Dexie'; import { PromiseExtended } from 'Dexie';
import { DexieMessageTable, MessageTable, MessageTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/message'; import { DexieMessageTable, MessageTable, MessageTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/message';
import { chatDatabase } from 'src/app/infra/database/dexie/instance/chat/service'; import { chatDatabase } from 'src/app/infra/database/dexie/instance/chat/service';
import { IDirectMessages, IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository'; import { IDirectMessages, IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
import { BehaviorSubject, combineLatest, from, Observable, Subject } from 'rxjs'; import { combineLatest, from, Observable, Subject } from 'rxjs';
import { filter, map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { err, ok } from 'neverthrow'; import { err, ok } from 'neverthrow';
@@ -8,9 +8,8 @@ import { NotificationListMapper } from '../domain/mapper/notificationListMapper'
import { NotificationTable } from './infra/db/notification.db'; import { NotificationTable } from './infra/db/notification.db';
import { Observable, Subject } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { filter } from 'rxjs/operators'; import { filter } from 'rxjs/operators';
import { NotificationMapper } from '../domain/mapper/notificationMapper';
import { NotificationLive } from './dto/NotificationLiveOutputDTO'; import { NotificationLive } from './dto/NotificationLiveOutputDTO';
import { NotificationReceiveService } from 'src/app/core/notification/use-case/notification-receive.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
@@ -21,16 +20,15 @@ export class NotificationRepositoryService {
constructor( constructor(
private RemoteNotificationService: RemoteNotificationService, private RemoteNotificationService: RemoteNotificationService,
private FirebasePushNotificationService: FirebasePushNotificationService, private FirebasePushNotificationService: FirebasePushNotificationService,
private LocalNotificationService: LocalNotificationService private LocalNotificationService: LocalNotificationService,
private NotificationReceiveService: NotificationReceiveService
) { ) {
this.FirebasePushNotificationService.onReceiveForeground(async (data)=> { this.NotificationReceiveService.execute((data) => {
this.notificationSubject.next(NotificationMapper(data));
console.log('FirebasePushNotificationService', data) console.log('FirebasePushNotificationService', data)
this.init() this.init();
}) })
if(SessionStore.user.UserId) { if(SessionStore.user.UserId) {
this.init() this.init()
} }
@@ -165,6 +165,9 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish, waitNThrow =
}, },
createSpan: (name, parent?: any) => { createSpan: (name, parent?: any) => {
return tracerInstance.startSpan(name, { root: false }, parent) as Span; return tracerInstance.startSpan(name, { root: false }, parent) as Span;
},
newTracer({bugPrint = false, name, autoFinish =false, waitNThrow = 0}) {
return createTracingInstance({bugPrint, name, module, autoFinish, waitNThrow})
} }
} }
@@ -285,6 +288,7 @@ export type TracingType = {
finish: () => void; finish: () => void;
hasError:(message: string, obj?: Object) => void; hasError:(message: string, obj?: Object) => void;
createSpan:(name, parent?: any) => Span; createSpan:(name, parent?: any) => Span;
newTracer:({name, bugPrint, autoFinish, daley, waitNThrow}: {name:string, bugPrint?:any, autoFinish?:any, daley?:any, waitNThrow?:any}) => TracingType;
}; };
export interface UserInteraction { export interface UserInteraction {
@@ -61,35 +61,46 @@ export class TaskDetailsPage implements OnInit {
setTimeout(() => { setTimeout(() => {
console.log('change', this.task.Note); console.log('change', this.task.Note);
// this.task.Note = this.sanitizeHtml(this.task.Note) as any // this.task.Note = this.sanitizeHtml(this.task.Note) as any
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note) if(this.text.nativeElement) {
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note)
}
}, 10) }, 10)
setTimeout(() => { setTimeout(() => {
console.log('change', this.task.Note); console.log('change', this.task.Note);
// this.task.Note = this.sanitizeHtml(this.task.Note) as any // this.task.Note = this.sanitizeHtml(this.task.Note) as any
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note) if(this.text.nativeElement) {
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note)
}
}, 100) }, 100)
setTimeout(() => { setTimeout(() => {
console.log('change', this.task.Note); console.log('change', this.task.Note);
// this.task.Note = this.sanitizeHtml(this.task.Note) as any // this.task.Note = this.sanitizeHtml(this.task.Note) as any
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note) if(this.text.nativeElement) {
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note)
}
}, 500) }, 500)
setTimeout(() => { setTimeout(() => {
console.log('change', this.task.Note); console.log('change', this.task.Note);
// this.task.Note = this.sanitizeHtml(this.task.Note) as any // this.task.Note = this.sanitizeHtml(this.task.Note) as any
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note) if(this.text.nativeElement) {
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note)
}
}, 1000) }, 1000)
setTimeout(() => { setTimeout(() => {
console.log('change', this.task.Note); console.log('change', this.task.Note);
// this.task.Note = this.sanitizeHtml(this.task.Note) as any // this.task.Note = this.sanitizeHtml(this.task.Note) as any
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note) if(this.text.nativeElement) {
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note)
}
}, 2000) }, 2000)
@@ -97,7 +108,9 @@ export class TaskDetailsPage implements OnInit {
setTimeout(() => { setTimeout(() => {
console.log('change', this.task.Note); console.log('change', this.task.Note);
// this.task.Note = this.sanitizeHtml(this.task.Note) as any // this.task.Note = this.sanitizeHtml(this.task.Note) as any
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note) if(this.text.nativeElement) {
(this.text.nativeElement as HTMLDivElement).innerHTML = this.decode(this.task.Note)
}
}, 4000) }, 4000)
+1 -1
View File
@@ -89,7 +89,7 @@
<span *ngIf="room.lastMessageAudio" class="item-files-title font-13-em"> audio </span> <span *ngIf="room.lastMessageAudio" class="item-files-title font-13-em"> audio </span>
<fa-icon *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.$id == selectedRoomId"></fa-icon> <fa-icon *ngIf="room?.messages?.[0]?.attachments[0]?.mimeType == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.$id == selectedRoomId"></fa-icon>
<fa-icon *ngIf="room.lastMessageImage" icon="image"></fa-icon> <fa-icon *ngIf="room.lastMessageImage" icon="image"></fa-icon>
<span class="pl-2 font-13-em add-ellipsis" *ngIf="!room.lastMessageAudio">{{ room.messages[0].attachments[0].description }}</span> <span class="pl-2 font-13-em add-ellipsis" *ngIf="!room.lastMessageAudio && !room.lastMessageImage">{{ room.messages[0].attachments[0].description }}</span>
</div> </div>
<!-- <div class="item-files" *ngIf="room.attachments"> <!-- <div class="item-files" *ngIf="room.attachments">
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = { export let versionData = {
"shortSHA": "53497407d", "shortSHA": "0c6fa3118",
"SHA": "53497407df3d29ef6c8e923f4d0f2f8ab51c7506", "SHA": "0c6fa3118e74cd62bad0a4f7e7add70287fe6b42",
"branch": "developer", "branch": "developer",
"lastCommitAuthor": "'Peter Maquiran'", "lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Fri Oct 25 12:23:58 2024 +0100'", "lastCommitTime": "'Fri Oct 25 12:24:53 2024 +0100'",
"lastCommitMessage": "remove console logs", "lastCommitMessage": "remove import",
"lastCommitNumber": "6120", "lastCommitNumber": "6121",
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 2 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/shared/gabinete-digital/generic/task-details/task-details.page.ts", "changeStatus": "On branch developer\nYour branch is up to date with 'origin/developer'.\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tnew file: doc/process.md\n\tmodified: src/app/core/chat/usecase/message/message-reaction-by-id-use-case.service.ts\n\tnew file: src/app/core/notification/use-case/notification-receive.service.ts\n\tmodified: src/app/infra/socket/signalR/signal-r.service.ts\n\tmodified: src/app/module/chat/data/repository/message/message-live-signalr-data-source.service.ts\n\tmodified: src/app/module/chat/data/repository/message/message-local-data-source.service.ts\n\tmodified: src/app/module/notification/data/notification-repository.service.ts\n\tmodified: src/app/services/monitoring/opentelemetry/tracer.ts\n\tmodified: src/app/shared/gabinete-digital/generic/task-details/task-details.page.ts\n\tmodified: src/app/ui/chat/chat.page.html\n\tmodified: version/git-version.ts",
"changeAuthor": "peter.maquiran" "changeAuthor": "peter.maquiran"
} }