@oneuptime/common 10.5.8 → 10.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/ExceptionInstance.ts +1 -1
- package/Models/AnalyticsModels/Log.ts +1 -1
- package/Models/AnalyticsModels/Metric.ts +1 -1
- package/Models/AnalyticsModels/Profile.ts +1 -1
- package/Models/AnalyticsModels/ProfileSample.ts +1 -1
- package/Models/AnalyticsModels/Span.ts +1 -1
- package/Models/DatabaseModels/SmsLog.ts +111 -0
- package/Models/DatabaseModels/TelemetryException.ts +46 -34
- package/Models/DatabaseModels/TelemetryUsageBilling.ts +35 -2
- package/Server/API/AIAgentDataAPI.ts +25 -7
- package/Server/API/DashboardAPI.ts +616 -0
- package/Server/API/TelemetryExceptionAPI.ts +6 -2
- package/Server/Infrastructure/Postgres/SchemaMigrations/1780317745887-AddDeliveryTrackingToSmsLog.ts +39 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1780381124553-MigrationName.ts +28 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1780382837019-MigrationName.ts +24 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1780387560604-MigrationName.ts +47 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1780388219225-MigrationName.ts +34 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -0
- package/Server/Infrastructure/QueueWorker.ts +40 -1
- package/Server/Services/AnalyticsDatabaseService.ts +87 -0
- package/Server/Services/DatabaseService.ts +73 -0
- package/Server/Services/TelemetryExceptionService.ts +24 -49
- package/Server/Services/TelemetryUsageBillingService.ts +289 -166
- package/Server/Types/AnalyticsDatabase/ModelPermission.ts +102 -72
- package/Server/Types/Database/Permissions/OwnedScopePermission.ts +81 -60
- package/Server/Types/Database/Permissions/OwnerTableRegistry.ts +67 -0
- package/Server/Utils/Logger.ts +12 -1
- package/Server/Utils/StartServer.ts +13 -5
- package/Server/Utils/Telemetry/ContextSpanProcessor.ts +48 -0
- package/Server/Utils/Telemetry/SpanUtil.ts +16 -35
- package/Server/Utils/Telemetry/TelemetryContext.ts +190 -0
- package/Server/Utils/Telemetry.ts +18 -2
- package/Types/Database/AccessControl/OwnedThrough.ts +31 -3
- package/Types/SmsStatus.ts +16 -0
- package/Types/Telemetry/ServiceType.ts +10 -0
- package/UI/Components/LogsViewer/LogsViewer.tsx +16 -0
- package/UI/Utils/Project.ts +6 -0
- package/UI/Utils/Telemetry/Telemetry.ts +65 -0
- package/UI/Utils/TelemetryService.ts +150 -0
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +1 -1
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Log.js +1 -1
- package/build/dist/Models/AnalyticsModels/Log.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Metric.js +1 -1
- package/build/dist/Models/AnalyticsModels/Metric.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Profile.js +1 -1
- package/build/dist/Models/AnalyticsModels/Profile.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/ProfileSample.js +1 -1
- package/build/dist/Models/AnalyticsModels/ProfileSample.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Span.js +1 -1
- package/build/dist/Models/AnalyticsModels/Span.js.map +1 -1
- package/build/dist/Models/DatabaseModels/SmsLog.js +112 -0
- package/build/dist/Models/DatabaseModels/SmsLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryException.js +47 -33
- package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryUsageBilling.js +36 -2
- package/build/dist/Models/DatabaseModels/TelemetryUsageBilling.js.map +1 -1
- package/build/dist/Server/API/AIAgentDataAPI.js +24 -8
- package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -1
- package/build/dist/Server/API/DashboardAPI.js +459 -2
- package/build/dist/Server/API/DashboardAPI.js.map +1 -1
- package/build/dist/Server/API/TelemetryExceptionAPI.js +6 -2
- package/build/dist/Server/API/TelemetryExceptionAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780317745887-AddDeliveryTrackingToSmsLog.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780317745887-AddDeliveryTrackingToSmsLog.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780381124553-MigrationName.js +23 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780381124553-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780382837019-MigrationName.js +19 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780382837019-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780387560604-MigrationName.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780387560604-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780388219225-MigrationName.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1780388219225-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +10 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/QueueWorker.js +31 -1
- package/build/dist/Server/Infrastructure/QueueWorker.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +59 -0
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +62 -0
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryExceptionService.js +16 -41
- package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryUsageBillingService.js +211 -147
- package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js +84 -63
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/OwnedScopePermission.js +67 -49
- package/build/dist/Server/Types/Database/Permissions/OwnedScopePermission.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/OwnerTableRegistry.js +51 -0
- package/build/dist/Server/Types/Database/Permissions/OwnerTableRegistry.js.map +1 -1
- package/build/dist/Server/Utils/Logger.js +8 -1
- package/build/dist/Server/Utils/Logger.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +12 -4
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/ContextSpanProcessor.js +37 -0
- package/build/dist/Server/Utils/Telemetry/ContextSpanProcessor.js.map +1 -0
- package/build/dist/Server/Utils/Telemetry/SpanUtil.js +15 -24
- package/build/dist/Server/Utils/Telemetry/SpanUtil.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/TelemetryContext.js +124 -0
- package/build/dist/Server/Utils/Telemetry/TelemetryContext.js.map +1 -0
- package/build/dist/Server/Utils/Telemetry.js +12 -1
- package/build/dist/Server/Utils/Telemetry.js.map +1 -1
- package/build/dist/Types/Database/AccessControl/OwnedThrough.js +7 -2
- package/build/dist/Types/Database/AccessControl/OwnedThrough.js.map +1 -1
- package/build/dist/Types/SmsStatus.js +15 -0
- package/build/dist/Types/SmsStatus.js.map +1 -1
- package/build/dist/Types/Telemetry/ServiceType.js +10 -0
- package/build/dist/Types/Telemetry/ServiceType.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +15 -0
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Utils/Project.js +5 -0
- package/build/dist/UI/Utils/Project.js.map +1 -1
- package/build/dist/UI/Utils/Telemetry/Telemetry.js +44 -0
- package/build/dist/UI/Utils/Telemetry/Telemetry.js.map +1 -1
- package/build/dist/UI/Utils/TelemetryService.js +113 -0
- package/build/dist/UI/Utils/TelemetryService.js.map +1 -0
- package/package.json +2 -2
|
@@ -15,7 +15,7 @@ import { SpanStatus } from "./Span";
|
|
|
15
15
|
import ServiceType from "../../Types/Telemetry/ServiceType";
|
|
16
16
|
|
|
17
17
|
@OperationalResource()
|
|
18
|
-
@OwnedThrough("serviceId", Service)
|
|
18
|
+
@OwnedThrough("serviceId", Service, { includeProjectScope: true })
|
|
19
19
|
export default class ExceptionInstance extends AnalyticsBaseModel {
|
|
20
20
|
public constructor() {
|
|
21
21
|
const projectIdColumn: AnalyticsTableColumn = new AnalyticsTableColumn({
|
|
@@ -16,7 +16,7 @@ import Service from "../DatabaseModels/Service";
|
|
|
16
16
|
import ServiceType from "../../Types/Telemetry/ServiceType";
|
|
17
17
|
|
|
18
18
|
@OperationalResource()
|
|
19
|
-
@OwnedThrough("serviceId", Service)
|
|
19
|
+
@OwnedThrough("serviceId", Service, { includeProjectScope: true })
|
|
20
20
|
export default class Log extends AnalyticsBaseModel {
|
|
21
21
|
public constructor() {
|
|
22
22
|
const projectIdColumn: AnalyticsTableColumn = new AnalyticsTableColumn({
|
|
@@ -28,7 +28,7 @@ export enum MetricPointType {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
@OperationalResource()
|
|
31
|
-
@OwnedThrough("serviceId", Service)
|
|
31
|
+
@OwnedThrough("serviceId", Service, { includeProjectScope: true })
|
|
32
32
|
export default class Metric extends AnalyticsBaseModel {
|
|
33
33
|
public constructor() {
|
|
34
34
|
const projectIdColumn: AnalyticsTableColumn = new AnalyticsTableColumn({
|
|
@@ -15,7 +15,7 @@ import Service from "../DatabaseModels/Service";
|
|
|
15
15
|
import ServiceType from "../../Types/Telemetry/ServiceType";
|
|
16
16
|
|
|
17
17
|
@OperationalResource()
|
|
18
|
-
@OwnedThrough("serviceId", Service)
|
|
18
|
+
@OwnedThrough("serviceId", Service, { includeProjectScope: true })
|
|
19
19
|
export default class Profile extends AnalyticsBaseModel {
|
|
20
20
|
public constructor() {
|
|
21
21
|
const projectIdColumn: AnalyticsTableColumn = new AnalyticsTableColumn({
|
|
@@ -15,7 +15,7 @@ import Service from "../DatabaseModels/Service";
|
|
|
15
15
|
import ServiceType from "../../Types/Telemetry/ServiceType";
|
|
16
16
|
|
|
17
17
|
@OperationalResource()
|
|
18
|
-
@OwnedThrough("serviceId", Service)
|
|
18
|
+
@OwnedThrough("serviceId", Service, { includeProjectScope: true })
|
|
19
19
|
export default class ProfileSample extends AnalyticsBaseModel {
|
|
20
20
|
public constructor() {
|
|
21
21
|
const projectIdColumn: AnalyticsTableColumn = new AnalyticsTableColumn({
|
|
@@ -47,7 +47,7 @@ export interface SpanLink {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@OperationalResource()
|
|
50
|
-
@OwnedThrough("serviceId", Service)
|
|
50
|
+
@OwnedThrough("serviceId", Service, { includeProjectScope: true })
|
|
51
51
|
export default class Span extends AnalyticsBaseModel {
|
|
52
52
|
public constructor() {
|
|
53
53
|
const projectIdColumn: AnalyticsTableColumn = new AnalyticsTableColumn({
|
|
@@ -9,6 +9,7 @@ import User from "./User";
|
|
|
9
9
|
import OnCallDutyPolicy from "./OnCallDutyPolicy";
|
|
10
10
|
import OnCallDutyPolicyEscalationRule from "./OnCallDutyPolicyEscalationRule";
|
|
11
11
|
import OnCallDutyPolicySchedule from "./OnCallDutyPolicySchedule";
|
|
12
|
+
import UserOnCallLogTimeline from "./UserOnCallLogTimeline";
|
|
12
13
|
import Team from "./Team";
|
|
13
14
|
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
14
15
|
import Route from "../../Types/API/Route";
|
|
@@ -258,6 +259,54 @@ export default class SmsLog extends BaseModel {
|
|
|
258
259
|
})
|
|
259
260
|
public status?: SmsStatus = undefined;
|
|
260
261
|
|
|
262
|
+
@ColumnAccessControl({
|
|
263
|
+
create: [],
|
|
264
|
+
read: [
|
|
265
|
+
Permission.ProjectOwner,
|
|
266
|
+
Permission.ProjectAdmin,
|
|
267
|
+
Permission.ProjectMember,
|
|
268
|
+
Permission.Viewer,
|
|
269
|
+
Permission.ReadSmsLog,
|
|
270
|
+
],
|
|
271
|
+
update: [],
|
|
272
|
+
})
|
|
273
|
+
@TableColumn({
|
|
274
|
+
required: false,
|
|
275
|
+
type: TableColumnType.ShortText,
|
|
276
|
+
title: "Provider Error Code",
|
|
277
|
+
description:
|
|
278
|
+
"Error code returned by the SMS provider (e.g. Twilio error code 30007 for carrier filtering) when the message could not be delivered.",
|
|
279
|
+
canReadOnRelationQuery: false,
|
|
280
|
+
example: "30007",
|
|
281
|
+
})
|
|
282
|
+
@Column({
|
|
283
|
+
nullable: true,
|
|
284
|
+
type: ColumnType.ShortText,
|
|
285
|
+
length: ColumnLength.ShortText,
|
|
286
|
+
})
|
|
287
|
+
public errorCode?: string = undefined;
|
|
288
|
+
|
|
289
|
+
@ColumnAccessControl({
|
|
290
|
+
create: [],
|
|
291
|
+
read: [],
|
|
292
|
+
update: [],
|
|
293
|
+
})
|
|
294
|
+
@TableColumn({
|
|
295
|
+
required: false,
|
|
296
|
+
type: TableColumnType.ShortText,
|
|
297
|
+
title: "Status Callback Token",
|
|
298
|
+
description:
|
|
299
|
+
"Secret token embedded in the provider delivery-status callback URL. Used to authenticate incoming delivery-status callbacks. Never exposed via the API.",
|
|
300
|
+
canReadOnRelationQuery: false,
|
|
301
|
+
hideColumnInDocumentation: true,
|
|
302
|
+
})
|
|
303
|
+
@Column({
|
|
304
|
+
nullable: true,
|
|
305
|
+
type: ColumnType.ShortText,
|
|
306
|
+
length: ColumnLength.ShortText,
|
|
307
|
+
})
|
|
308
|
+
public statusCallbackToken?: string = undefined;
|
|
309
|
+
|
|
261
310
|
@ColumnAccessControl({
|
|
262
311
|
create: [],
|
|
263
312
|
read: [
|
|
@@ -895,6 +944,68 @@ export default class SmsLog extends BaseModel {
|
|
|
895
944
|
})
|
|
896
945
|
public onCallDutyPolicyScheduleId?: ObjectID = undefined;
|
|
897
946
|
|
|
947
|
+
@ColumnAccessControl({
|
|
948
|
+
create: [],
|
|
949
|
+
read: [
|
|
950
|
+
Permission.ProjectOwner,
|
|
951
|
+
Permission.ProjectAdmin,
|
|
952
|
+
Permission.ProjectMember,
|
|
953
|
+
Permission.Viewer,
|
|
954
|
+
Permission.ReadSmsLog,
|
|
955
|
+
],
|
|
956
|
+
update: [],
|
|
957
|
+
})
|
|
958
|
+
@TableColumn({
|
|
959
|
+
manyToOneRelationColumn: "userOnCallLogTimelineId",
|
|
960
|
+
type: TableColumnType.Entity,
|
|
961
|
+
modelType: UserOnCallLogTimeline,
|
|
962
|
+
title: "User On-Call Log Timeline",
|
|
963
|
+
description:
|
|
964
|
+
"On-call notification timeline entry this SMS was sent for (if any). Lets the delivery outcome be reflected back onto the on-call log.",
|
|
965
|
+
example: "f1a2b3c4-d5e6-47f8-9a0b-1c2d3e4f5a6b",
|
|
966
|
+
})
|
|
967
|
+
@ManyToOne(
|
|
968
|
+
() => {
|
|
969
|
+
return UserOnCallLogTimeline;
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
eager: false,
|
|
973
|
+
nullable: true,
|
|
974
|
+
onDelete: "CASCADE",
|
|
975
|
+
orphanedRowAction: "nullify",
|
|
976
|
+
},
|
|
977
|
+
)
|
|
978
|
+
@JoinColumn({ name: "userOnCallLogTimelineId" })
|
|
979
|
+
public userOnCallLogTimeline?: UserOnCallLogTimeline = undefined;
|
|
980
|
+
|
|
981
|
+
@ColumnAccessControl({
|
|
982
|
+
create: [],
|
|
983
|
+
read: [
|
|
984
|
+
Permission.ProjectOwner,
|
|
985
|
+
Permission.ProjectAdmin,
|
|
986
|
+
Permission.ProjectMember,
|
|
987
|
+
Permission.Viewer,
|
|
988
|
+
Permission.ReadSmsLog,
|
|
989
|
+
],
|
|
990
|
+
update: [],
|
|
991
|
+
})
|
|
992
|
+
@Index()
|
|
993
|
+
@TableColumn({
|
|
994
|
+
type: TableColumnType.ObjectID,
|
|
995
|
+
required: false,
|
|
996
|
+
canReadOnRelationQuery: true,
|
|
997
|
+
title: "User On-Call Log Timeline ID",
|
|
998
|
+
description:
|
|
999
|
+
"ID of the on-call notification timeline entry this SMS was sent for (if any).",
|
|
1000
|
+
example: "f1a2b3c4-d5e6-47f8-9a0b-1c2d3e4f5a6b",
|
|
1001
|
+
})
|
|
1002
|
+
@Column({
|
|
1003
|
+
type: ColumnType.ObjectID,
|
|
1004
|
+
nullable: true,
|
|
1005
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
1006
|
+
})
|
|
1007
|
+
public userOnCallLogTimelineId?: ObjectID = undefined;
|
|
1008
|
+
|
|
898
1009
|
@ColumnAccessControl({
|
|
899
1010
|
create: [],
|
|
900
1011
|
read: [
|
|
@@ -17,9 +17,13 @@ import TenantColumn from "../../Types/Database/TenantColumn";
|
|
|
17
17
|
import IconProp from "../../Types/Icon/IconProp";
|
|
18
18
|
import ObjectID from "../../Types/ObjectID";
|
|
19
19
|
import Permission from "../../Types/Permission";
|
|
20
|
+
import ServiceType from "../../Types/Telemetry/ServiceType";
|
|
20
21
|
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
|
|
21
22
|
import DatabaseBaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
22
23
|
import Service from "./Service";
|
|
24
|
+
import Host from "./Host";
|
|
25
|
+
import DockerHost from "./DockerHost";
|
|
26
|
+
import KubernetesCluster from "./KubernetesCluster";
|
|
23
27
|
|
|
24
28
|
@EnableDocumentation()
|
|
25
29
|
@CanAccessIfCanReadOn("service")
|
|
@@ -60,7 +64,16 @@ import Service from "./Service";
|
|
|
60
64
|
tableDescription:
|
|
61
65
|
"List of all Telemetry Exceptions created for the telemetry service for this OneUptime project and it's status.",
|
|
62
66
|
})
|
|
63
|
-
|
|
67
|
+
/*
|
|
68
|
+
* serviceId is polymorphic (see the column below) — it may reference a
|
|
69
|
+
* Service, Host, DockerHost or KubernetesCluster, or be the projectId for
|
|
70
|
+
* unattributed (Unknown) telemetry. Owned scope unions ownership across all
|
|
71
|
+
* of those resource types, and includeProjectScope lets in-project users
|
|
72
|
+
* see the unattributed bucket (which has no owner resource).
|
|
73
|
+
*/
|
|
74
|
+
@OwnedThrough("serviceId", [Service, Host, DockerHost, KubernetesCluster], {
|
|
75
|
+
includeProjectScope: true,
|
|
76
|
+
})
|
|
64
77
|
@Entity({
|
|
65
78
|
name: "TelemetryException",
|
|
66
79
|
})
|
|
@@ -150,6 +163,15 @@ export default class TelemetryException extends DatabaseBaseModel {
|
|
|
150
163
|
})
|
|
151
164
|
public projectId?: ObjectID = undefined;
|
|
152
165
|
|
|
166
|
+
/*
|
|
167
|
+
* serviceId is polymorphic (disambiguated by serviceType, mirroring the
|
|
168
|
+
* ClickHouse ExceptionInstance rows): it can be a real Service, a Host /
|
|
169
|
+
* DockerHost / KubernetesCluster id, or the projectId for unattributed
|
|
170
|
+
* (Unknown) telemetry. There is intentionally NO @ManyToOne(Service)
|
|
171
|
+
* relation — a Service join would only resolve OpenTelemetry rows and
|
|
172
|
+
* silently null out everything else. The read side resolves serviceId +
|
|
173
|
+
* serviceType to a resource per type (TelemetryServiceUtil) instead.
|
|
174
|
+
*/
|
|
153
175
|
@ColumnAccessControl({
|
|
154
176
|
create: [
|
|
155
177
|
Permission.ProjectOwner,
|
|
@@ -172,27 +194,21 @@ export default class TelemetryException extends DatabaseBaseModel {
|
|
|
172
194
|
Permission.EditTelemetryException,
|
|
173
195
|
],
|
|
174
196
|
})
|
|
197
|
+
@Index()
|
|
175
198
|
@TableColumn({
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
199
|
+
type: TableColumnType.ObjectID,
|
|
200
|
+
required: true,
|
|
201
|
+
title: "Service ID",
|
|
202
|
+
description:
|
|
203
|
+
"ID of the resource this exception belongs to (Service / Host / DockerHost / KubernetesCluster, or the projectId for unattributed telemetry — disambiguated by serviceType).",
|
|
181
204
|
example: "d4e5f6a7-b8c9-0123-def1-234567890123",
|
|
182
205
|
})
|
|
183
|
-
@
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
nullable: true,
|
|
190
|
-
onDelete: "CASCADE",
|
|
191
|
-
orphanedRowAction: "nullify",
|
|
192
|
-
},
|
|
193
|
-
)
|
|
194
|
-
@JoinColumn({ name: "serviceId" })
|
|
195
|
-
public service?: Service = undefined;
|
|
206
|
+
@Column({
|
|
207
|
+
type: ColumnType.ObjectID,
|
|
208
|
+
nullable: false,
|
|
209
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
210
|
+
})
|
|
211
|
+
public serviceId?: ObjectID = undefined;
|
|
196
212
|
|
|
197
213
|
@ColumnAccessControl({
|
|
198
214
|
create: [
|
|
@@ -210,26 +226,22 @@ export default class TelemetryException extends DatabaseBaseModel {
|
|
|
210
226
|
Permission.TelemetryViewer,
|
|
211
227
|
Permission.ReadTelemetryException,
|
|
212
228
|
],
|
|
213
|
-
update: [
|
|
214
|
-
Permission.ProjectOwner,
|
|
215
|
-
Permission.ProjectAdmin,
|
|
216
|
-
Permission.EditTelemetryException,
|
|
217
|
-
],
|
|
229
|
+
update: [],
|
|
218
230
|
})
|
|
219
|
-
@Index()
|
|
220
231
|
@TableColumn({
|
|
221
|
-
type: TableColumnType.
|
|
222
|
-
|
|
223
|
-
title: "Service
|
|
224
|
-
description:
|
|
225
|
-
|
|
232
|
+
type: TableColumnType.ShortText,
|
|
233
|
+
canReadOnRelationQuery: true,
|
|
234
|
+
title: "Service Type",
|
|
235
|
+
description:
|
|
236
|
+
"Resource type that produced this exception (e.g. OpenTelemetry service, Host, DockerHost, KubernetesCluster, or Unknown for unattributed telemetry).",
|
|
237
|
+
example: "OpenTelemetry",
|
|
226
238
|
})
|
|
227
239
|
@Column({
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
240
|
+
nullable: true,
|
|
241
|
+
type: ColumnType.ShortText,
|
|
242
|
+
length: ColumnLength.ShortText,
|
|
231
243
|
})
|
|
232
|
-
public
|
|
244
|
+
public serviceType?: ServiceType = undefined;
|
|
233
245
|
|
|
234
246
|
@ColumnAccessControl({
|
|
235
247
|
create: [
|
|
@@ -15,6 +15,7 @@ import TenantColumn from "../../Types/Database/TenantColumn";
|
|
|
15
15
|
import Decimal from "../../Types/Decimal";
|
|
16
16
|
import IconProp from "../../Types/Icon/IconProp";
|
|
17
17
|
import ProductType from "../../Types/MeteredPlan/ProductType";
|
|
18
|
+
import ServiceType from "../../Types/Telemetry/ServiceType";
|
|
18
19
|
import ObjectID from "../../Types/ObjectID";
|
|
19
20
|
import Permission from "../../Types/Permission";
|
|
20
21
|
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
|
|
@@ -270,8 +271,16 @@ export default class TelemetryUsageBilling extends BaseModel {
|
|
|
270
271
|
{
|
|
271
272
|
eager: false,
|
|
272
273
|
nullable: true,
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
/*
|
|
275
|
+
* No DB-level foreign key. Telemetry that arrives without a
|
|
276
|
+
* service.name is metered against a synthetic "unattributed"
|
|
277
|
+
* bucket whose serviceId is the projectId (ServiceType.Unknown),
|
|
278
|
+
* which has no matching Service row — a FK would reject those
|
|
279
|
+
* billing rows. The relation is kept for read-side joins; it
|
|
280
|
+
* resolves to null for the unattributed bucket and the UI renders
|
|
281
|
+
* a synthetic "Unknown Service" in its place.
|
|
282
|
+
*/
|
|
283
|
+
createForeignKeyConstraints: false,
|
|
275
284
|
},
|
|
276
285
|
)
|
|
277
286
|
@JoinColumn({ name: "serviceId" })
|
|
@@ -301,6 +310,30 @@ export default class TelemetryUsageBilling extends BaseModel {
|
|
|
301
310
|
})
|
|
302
311
|
public serviceId?: ObjectID = undefined;
|
|
303
312
|
|
|
313
|
+
@ColumnAccessControl({
|
|
314
|
+
create: [],
|
|
315
|
+
read: [
|
|
316
|
+
Permission.ProjectOwner,
|
|
317
|
+
Permission.ProjectAdmin,
|
|
318
|
+
Permission.ManageProjectBilling,
|
|
319
|
+
],
|
|
320
|
+
update: [],
|
|
321
|
+
})
|
|
322
|
+
@TableColumn({
|
|
323
|
+
type: TableColumnType.ShortText,
|
|
324
|
+
canReadOnRelationQuery: true,
|
|
325
|
+
title: "Service Type",
|
|
326
|
+
description:
|
|
327
|
+
"Resource type that produced this telemetry (e.g. OpenTelemetry service, Host, DockerHost, KubernetesCluster, or Unknown for unattributed telemetry).",
|
|
328
|
+
example: "OpenTelemetry",
|
|
329
|
+
})
|
|
330
|
+
@Column({
|
|
331
|
+
nullable: true,
|
|
332
|
+
type: ColumnType.ShortText,
|
|
333
|
+
length: ColumnLength.ShortText,
|
|
334
|
+
})
|
|
335
|
+
public serviceType?: ServiceType = undefined;
|
|
336
|
+
|
|
304
337
|
@ColumnAccessControl({
|
|
305
338
|
create: [],
|
|
306
339
|
read: [],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AIAgentService from "../Services/AIAgentService";
|
|
2
2
|
import LlmProviderService from "../Services/LlmProviderService";
|
|
3
3
|
import TelemetryExceptionService from "../Services/TelemetryExceptionService";
|
|
4
|
+
import ServiceService from "../Services/ServiceService";
|
|
4
5
|
import ServiceCodeRepositoryService from "../Services/ServiceCodeRepositoryService";
|
|
5
6
|
import CodeRepositoryService from "../Services/CodeRepositoryService";
|
|
6
7
|
import AIAgentTaskPullRequestService from "../Services/AIAgentTaskPullRequestService";
|
|
@@ -15,6 +16,7 @@ import Response from "../Utils/Response";
|
|
|
15
16
|
import AIAgent from "../../Models/DatabaseModels/AIAgent";
|
|
16
17
|
import LlmProvider from "../../Models/DatabaseModels/LlmProvider";
|
|
17
18
|
import TelemetryException from "../../Models/DatabaseModels/TelemetryException";
|
|
19
|
+
import Service from "../../Models/DatabaseModels/Service";
|
|
18
20
|
import ServiceCodeRepository from "../../Models/DatabaseModels/ServiceCodeRepository";
|
|
19
21
|
import CodeRepository from "../../Models/DatabaseModels/CodeRepository";
|
|
20
22
|
import AIAgentTaskPullRequest from "../../Models/DatabaseModels/AIAgentTaskPullRequest";
|
|
@@ -174,11 +176,7 @@ export default class AIAgentDataAPI {
|
|
|
174
176
|
exceptionType: true,
|
|
175
177
|
fingerprint: true,
|
|
176
178
|
serviceId: true,
|
|
177
|
-
|
|
178
|
-
_id: true,
|
|
179
|
-
name: true,
|
|
180
|
-
description: true,
|
|
181
|
-
},
|
|
179
|
+
serviceType: true,
|
|
182
180
|
},
|
|
183
181
|
props: {
|
|
184
182
|
isRoot: true,
|
|
@@ -198,6 +196,26 @@ export default class AIAgentDataAPI {
|
|
|
198
196
|
getLogAttributesFromRequest(req as any),
|
|
199
197
|
);
|
|
200
198
|
|
|
199
|
+
/*
|
|
200
|
+
* serviceId is polymorphic — resolve the Service only when it is
|
|
201
|
+
* a real Service. findOneById returns null for Host / DockerHost /
|
|
202
|
+
* KubernetesCluster / unattributed serviceIds (they aren't
|
|
203
|
+
* Services), preserving the previous "name only for real
|
|
204
|
+
* services" behaviour without the dropped ORM relation.
|
|
205
|
+
*/
|
|
206
|
+
const exceptionService: Service | null = exception.serviceId
|
|
207
|
+
? await ServiceService.findOneById({
|
|
208
|
+
id: exception.serviceId,
|
|
209
|
+
select: {
|
|
210
|
+
name: true,
|
|
211
|
+
description: true,
|
|
212
|
+
},
|
|
213
|
+
props: {
|
|
214
|
+
isRoot: true,
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
: null;
|
|
218
|
+
|
|
201
219
|
return Response.sendJsonObjectResponse(req, res, {
|
|
202
220
|
exception: {
|
|
203
221
|
id: exception._id?.toString(),
|
|
@@ -209,8 +227,8 @@ export default class AIAgentDataAPI {
|
|
|
209
227
|
service: exception.serviceId
|
|
210
228
|
? {
|
|
211
229
|
id: exception.serviceId.toString(),
|
|
212
|
-
name:
|
|
213
|
-
description:
|
|
230
|
+
name: exceptionService?.name,
|
|
231
|
+
description: exceptionService?.description,
|
|
214
232
|
}
|
|
215
233
|
: null,
|
|
216
234
|
});
|