oneuptime/Common/Server/Services/ServiceTelemetryServiceService.ts
Nawaz Dhandala 21232465bc
feat: Add Service Owners, Settings, Side Menu, Telemetry Services, and Traces pages
- Implemented Service Owners page with team and user management.
- Created Service Settings page for configuring service properties.
- Developed a Side Menu for navigation within the service view.
- Added Telemetry Services page to manage telemetry service assignments.
- Introduced Traces page to display trace data for assigned telemetry services.
- Updated routing to include new service-related pages.
- Enhanced breadcrumbs for improved navigation context.
2026-01-09 13:53:21 +00:00

59 lines
1.8 KiB
TypeScript

import BadDataException from "../../Types/Exception/BadDataException";
import CreateBy from "../Types/Database/CreateBy";
import { OnCreate } from "../Types/Database/Hooks";
import DatabaseService from "./DatabaseService";
import Model from "../../Models/DatabaseModels/ServiceTelemetryService";
import ObjectID from "../../Types/ObjectID";
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
export class Service extends DatabaseService<Model> {
public constructor() {
super(Model);
}
@CaptureSpan()
protected override async onBeforeCreate(
createBy: CreateBy<Model>,
): Promise<OnCreate<Model>> {
// select a random color.
if (!createBy.data.serviceId && !createBy.data.service) {
throw new BadDataException("service is required");
}
if (!createBy.data.telemetryService && !createBy.data.telemetryServiceId) {
throw new BadDataException("telemetryService is required");
}
// serviceId and dependencyServiceId should not be the same
const serviceId: string | ObjectID | undefined =
createBy.data.serviceId || createBy.data.service?._id;
const telemetryServiceId: string | ObjectID | undefined =
createBy.data.telemetryServiceId || createBy.data.telemetryService?._id;
// check if this telemetryService is already added to the service for this service.
const existingtelemetryService: Model | null = await this.findOneBy({
query: {
serviceId: serviceId as ObjectID,
telemetryServiceId: telemetryServiceId as ObjectID,
},
props: {
isRoot: true,
},
});
if (existingtelemetryService) {
throw new BadDataException(
"Telemetry Service already exists for this service",
);
}
return {
carryForward: null,
createBy: createBy,
};
}
}
export default new Service();