mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: update type handling and add ProfileMonitorResponse support in telemetry monitor
This commit is contained in:
@@ -233,7 +233,7 @@ const DashboardLogStreamComponentElement: FunctionComponent<ComponentProps> = (
|
||||
const colors: SeverityColor = getSeverityColor(severity);
|
||||
const body: string = (log.body as string) || "";
|
||||
const time: Date | undefined = log.time
|
||||
? OneUptimeDate.fromString(log.time as string)
|
||||
? OneUptimeDate.fromString(log.time as unknown as string)
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
|
||||
@@ -247,7 +247,7 @@ const DashboardTraceListComponentElement: FunctionComponent<ComponentProps> = (
|
||||
const durationNano: number =
|
||||
(span.durationUnixNano as number) || 0;
|
||||
const startTime: Date | undefined = span.startTime
|
||||
? OneUptimeDate.fromString(span.startTime as string)
|
||||
? OneUptimeDate.fromString(span.startTime as unknown as string)
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
|
||||
@@ -221,13 +221,13 @@ const DiffFlamegraph: FunctionComponent<DiffFlamegraphProps> = (
|
||||
|
||||
const renderNode: (
|
||||
node: DiffFlamegraphNode,
|
||||
parentMax: number,
|
||||
_parentMax: number,
|
||||
depth: number,
|
||||
offsetFraction: number,
|
||||
widthFraction: number,
|
||||
) => ReactElement | null = (
|
||||
node: DiffFlamegraphNode,
|
||||
parentMax: number,
|
||||
_parentMax: number,
|
||||
depth: number,
|
||||
offsetFraction: number,
|
||||
widthFraction: number,
|
||||
|
||||
@@ -795,11 +795,11 @@ router.post(
|
||||
|
||||
const request: FlamegraphRequest = {
|
||||
projectId: databaseProps.tenantId,
|
||||
profileId,
|
||||
startTime,
|
||||
endTime,
|
||||
serviceIds,
|
||||
profileType,
|
||||
...(profileId !== undefined && { profileId }),
|
||||
...(startTime !== undefined && { startTime }),
|
||||
...(endTime !== undefined && { endTime }),
|
||||
...(serviceIds !== undefined && { serviceIds }),
|
||||
...(profileType !== undefined && { profileType }),
|
||||
};
|
||||
|
||||
const flamegraph: ProfileFlamegraphNode =
|
||||
@@ -869,10 +869,10 @@ router.post(
|
||||
projectId: databaseProps.tenantId,
|
||||
startTime,
|
||||
endTime,
|
||||
serviceIds,
|
||||
profileType,
|
||||
limit,
|
||||
sortBy,
|
||||
...(serviceIds !== undefined && { serviceIds }),
|
||||
...(profileType !== undefined && { profileType }),
|
||||
...(limit !== undefined && { limit }),
|
||||
...(sortBy !== undefined && { sortBy }),
|
||||
};
|
||||
|
||||
const functions: Array<FunctionListItem> =
|
||||
@@ -920,7 +920,7 @@ router.get(
|
||||
}
|
||||
|
||||
// Fetch profile metadata
|
||||
const profiles: Array<Profile> = (
|
||||
const profiles: Array<Profile> =
|
||||
await ProfileService.findBy({
|
||||
query: {
|
||||
projectId: databaseProps.tenantId,
|
||||
@@ -941,8 +941,7 @@ router.get(
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
});
|
||||
|
||||
if (!profiles[0]) {
|
||||
return Response.sendErrorResponse(
|
||||
@@ -955,7 +954,7 @@ router.get(
|
||||
const profile: Profile = profiles[0];
|
||||
|
||||
// Fetch profile samples
|
||||
const samplesResult: Array<ProfileSample> = (
|
||||
const samplesResult: Array<ProfileSample> =
|
||||
await ProfileSampleService.findBy({
|
||||
query: {
|
||||
projectId: databaseProps.tenantId,
|
||||
@@ -974,8 +973,7 @@ router.get(
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
});
|
||||
|
||||
const pprofSamples: Array<PprofSample> = samplesResult.map(
|
||||
(sample: ProfileSample): PprofSample => {
|
||||
@@ -1090,8 +1088,8 @@ router.post(
|
||||
baselineEndTime,
|
||||
comparisonStartTime,
|
||||
comparisonEndTime,
|
||||
serviceIds,
|
||||
profileType,
|
||||
...(serviceIds !== undefined && { serviceIds }),
|
||||
...(profileType !== undefined && { profileType }),
|
||||
};
|
||||
|
||||
const diffFlamegraph: DiffFlamegraphNode =
|
||||
|
||||
@@ -296,8 +296,8 @@ export class ProfileAggregationService {
|
||||
projectId: request.projectId,
|
||||
startTime: request.baselineStartTime,
|
||||
endTime: request.baselineEndTime,
|
||||
serviceIds: request.serviceIds,
|
||||
profileType: request.profileType,
|
||||
...(request.serviceIds !== undefined && { serviceIds: request.serviceIds }),
|
||||
...(request.profileType !== undefined && { profileType: request.profileType }),
|
||||
});
|
||||
|
||||
const comparisonTree: ProfileFlamegraphNode =
|
||||
@@ -305,8 +305,8 @@ export class ProfileAggregationService {
|
||||
projectId: request.projectId,
|
||||
startTime: request.comparisonStartTime,
|
||||
endTime: request.comparisonEndTime,
|
||||
serviceIds: request.serviceIds,
|
||||
profileType: request.profileType,
|
||||
...(request.serviceIds !== undefined && { serviceIds: request.serviceIds }),
|
||||
...(request.profileType !== undefined && { profileType: request.profileType }),
|
||||
});
|
||||
|
||||
return ProfileAggregationService.mergeDiffTrees(
|
||||
|
||||
@@ -208,11 +208,11 @@ export default class PprofEncoder {
|
||||
profile: PprofProfile,
|
||||
): Promise<Buffer> {
|
||||
const pprofData: PprofProto = PprofEncoder.encode(profile);
|
||||
const jsonBytes: Buffer = Buffer.from(JSON.stringify(pprofData), "utf-8");
|
||||
const jsonString: string = JSON.stringify(pprofData);
|
||||
|
||||
return new Promise<Buffer>(
|
||||
(resolve: (value: Buffer) => void, reject: (reason: Error) => void) => {
|
||||
zlib.gzip(jsonBytes, (err: Error | null, result: Buffer) => {
|
||||
zlib.gzip(jsonString, (err: Error | null, result: Buffer) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
|
||||
@@ -143,6 +143,7 @@ RunCron(
|
||||
| TraceMonitorResponse
|
||||
| MetricMonitorResponse
|
||||
| ExceptionMonitorResponse
|
||||
| ProfileMonitorResponse
|
||||
>
|
||||
> = [];
|
||||
|
||||
@@ -179,6 +180,7 @@ RunCron(
|
||||
| TraceMonitorResponse
|
||||
| MetricMonitorResponse
|
||||
| ExceptionMonitorResponse
|
||||
| ProfileMonitorResponse
|
||||
> = await Promise.all(monitorResponses);
|
||||
|
||||
for (const response of responses) {
|
||||
@@ -197,6 +199,7 @@ type MonitorTelemetryMonitorFunction = (data: {
|
||||
| TraceMonitorResponse
|
||||
| MetricMonitorResponse
|
||||
| ExceptionMonitorResponse
|
||||
| ProfileMonitorResponse
|
||||
>;
|
||||
|
||||
const monitorTelemetryMonitor: MonitorTelemetryMonitorFunction = async (data: {
|
||||
@@ -209,6 +212,7 @@ const monitorTelemetryMonitor: MonitorTelemetryMonitorFunction = async (data: {
|
||||
| TraceMonitorResponse
|
||||
| MetricMonitorResponse
|
||||
| ExceptionMonitorResponse
|
||||
| ProfileMonitorResponse
|
||||
> => {
|
||||
const { monitorStep, monitorType, monitorId, projectId } = data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user